Skip Navigation

This is the technical support forum for WPML - the multilingual WordPress plugin.

Everyone can read, but only WPML clients can post here. WPML team is replying on the forum 6 days per week, 22 hours per day.

Our next available supporter will start replying to tickets in about 2.29 hours from now. Thank you for your understanding.

Sun Mon Tue Wed Thu Fri Sat
- 10:00 – 17:00 10:00 – 17:00 10:00 – 17:00 10:00 – 17:00 10:00 – 17:00 -
- 18:00 – 19:00 18:00 – 19:00 18:00 – 19:00 18:00 – 19:00 18:00 – 19:00 -

Supporter timezone: Asia/Kathmandu (GMT+05:45)

Tagged: 

This topic contains 16 replies, has 2 voices.

Last updated by Angeloca 2 months, 4 weeks ago.

Assisted by: Shekhar Bhandari.

Author Posts
January 15, 2024 at 2:52 pm #15185894

Angeloca

Hi,
I'm hooking into the wp_after_insert_post action to save some post data in a custom database table.

The problem is that when completing the first translation (first translation meaning that you "complete" the translation for the first time) with the Advanced Translation Editor, the custom fields (created with ACF -- setup as "copy") apparently are not yet saved into the postmeta table.

Any advice?

Thanks

January 16, 2024 at 6:01 am #15187741

Shekhar Bhandari
Supporter

Languages: English (English )

Timezone: Asia/Kathmandu (GMT+05:45)

Hello Angeloca,

Welcome to WPML support. I'd be happy to help you with this.

Can you provide me with a test staging site where I can check this? To debug this issue further, I would need to check your site settings once, for this I would need temporary access (wp-admin and ftp) to your site.

So could you please provide me with those details, you will find the needed fields for this below the comment area when you log in to leave your next reply.
hidden link

This info is private and available to you and WPML supporters only.
Read more about this: https://wpml.org/purchase/support-policy/privacy-and-security-when-providing-debug-information-for-support/

Note:
Backup your sites before providing the credentials or if possible provide credentials for the test site
Provide the link where the code is added
Provide me permission to disable/enable everything on the test site.

Look forward to your reply.

Thanks

January 16, 2024 at 11:09 am #15189378

Angeloca

Hi Shekar, I'll setup a staging with the base theme and no plugins, it will take a couple of days

January 16, 2024 at 11:24 am #15189509

Shekhar Bhandari
Supporter

Languages: English (English )

Timezone: Asia/Kathmandu (GMT+05:45)

Sure, update me further when the test site is ready.

January 17, 2024 at 4:41 pm #15196097

Angeloca

Hi Shekhar, can you activate the privare reply form?

January 18, 2024 at 3:47 am #15197568

Shekhar Bhandari
Supporter

Languages: English (English )

Timezone: Asia/Kathmandu (GMT+05:45)

Sure, enabled the private reply for you.

January 18, 2024 at 12:09 pm #15199597

Shekhar Bhandari
Supporter

Languages: English (English )

Timezone: Asia/Kathmandu (GMT+05:45)

Hello there,

Can you try to use the https://developer.wordpress.org/reference/functions/wp_update_post/ hook instead of save_post and see if it helps?

You can also use the hook https://wpml.org/documentation/support/wpml-coding-api/wpml-hooks-reference/#hook-1560761 to synchronize the post meta.

Look forward to your reply.

Thanks

January 19, 2024 at 10:57 am #15204245

Angeloca

Hi Shekhar,
the save_post is triggered before the wp_after_insert, so I think that if there are no meta available in insert, they will not be available in save.

What happens to the do_action( 'wpml_sync_all_custom_fields', $id) if I pass the ID of the original post in the main language?

January 19, 2024 at 12:54 pm #15205038

Shekhar Bhandari
Supporter

Languages: English (English )

Timezone: Asia/Kathmandu (GMT+05:45)

Hello there,

It Synchronizes the values of all custom fields across all translations of a given post. It only does it if the translation option for these custom fields is set to Copy.

Let me know if this helps.

Thanks

January 22, 2024 at 9:52 am #15210176

Angeloca

Hi Shehkar,
I've tested the action, but unfortunately it's not working.

I've added the sync just at the beginning of the save_post method, but still meta is absent upon first save :-/

January 22, 2024 at 11:30 am #15211005

Shekhar Bhandari
Supporter

Languages: English (English )

Timezone: Asia/Kathmandu (GMT+05:45)

Hello there,

Since what you are doing is a custom code debugging custom code is not included in the support.

At this point, I would suggest you consider contacting one of our certified partners from this link: http://wpml.org/documentation/support/wpml-contractors/

Before doing so please have a look also here:
http://wpml.org/documentation/support/wpml-contractors/guidelines-for-people-looking-for-consulting-help/

You will get the custom assistance you need to get on with your project.

I am sorry, I couldn't be much help here.

Thanks

January 22, 2024 at 4:22 pm #15212815

Angeloca

Hi Shekar,
there's clearly something off in the way ATE is firing the wp_after_insert_post because at this point the postmeta should be available.

January 23, 2024 at 4:00 am #15214013

Shekhar Bhandari
Supporter

Languages: English (English )

Timezone: Asia/Kathmandu (GMT+05:45)

Hello there,

I have created a test site here: hidden link can you create a simple example page with demo data and add the function so we can debug this further, No need to add the full code, you can just vardump the results to show the issue.

Look forward to your reply.

Thanks

January 25, 2024 at 4:02 pm #15227261

Angeloca

Hi Shekhar, thank you.

I've added the code in functions.php:658 of the 2021 theme.

Just create a new post, fill the custom field created with acf (not required though), publish, translate once, you'll see that no meta is printed in the errorlog upon saving the translation the first time.

Just beware that it will save when you publish the post in the original language 🙂

January 29, 2024 at 5:47 am #15236035

Shekhar Bhandari
Supporter

Languages: English (English )

Timezone: Asia/Kathmandu (GMT+05:45)

Hello there,

I am discussing this issue with our 2nd tier supporters and will update you further soon.

Thanks

The topic ‘[Closed] Advanced Translation Editor and wp_after_insert_post hook’ is closed to new replies.