Skip Navigation

This thread is resolved. Here is a description of the problem and solution.

Problem:
You are trying to run custom actions when translated posts are saved using WPML, but the standard

save_post

hook no longer works after switching to automatic translation.
Solution:
We recommend using WPML-specific hooks that are triggered during the translation process. A useful hook for your case is

wpml_pro_translation_completed

, which fires when an automatic translation is completed. Here's how you can use it:

add_action( 'wpml_pro_translation_completed', function( $post_id ) {// Custom action for translated posts});

If you need to catch updates to translated posts in general, another option is

wpml_sync_duplicate_content

, depending on your specific setup.

Please note that this solution might be irrelevant if it's outdated or not applicable to your case. We highly recommend checking related known issues at https://wpml.org/known-issues/, verifying the version of the permanent fix, and confirming that you have installed the latest versions of themes and plugins. If this does not resolve your issue, please open a new support ticket at WPML support forum.

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.

Tagged: 

This topic contains 0 reply, has 0 voices.

Last updated by ghledisC 3 months, 2 weeks ago.

Assisted by: Mihai Apetrei.

Author Posts
February 24, 2025 at 1:28 pm #16741149

ghledisC

Background of the issue:
I am trying to run custom actions when translated posts are saved using WPML. Previously, I used the save_post hook for these actions before switching to automatic translation.

Symptoms:
The custom actions that used to activate on save_post no longer work with any standard WordPress hook after switching to automatic translation.

Questions:
What hook can I use to run customizations when translated posts are saved?

February 24, 2025 at 6:02 pm #16742597

Mihai Apetrei
WPML Supporter since 03/2018

Languages: English (English )

Timezone: Europe/Bucharest (GMT+03:00)

Hey there! I’m back!

This has been an interesting challenge, and I understand why it’s happening. When switching to automatic translation, WPML doesn’t trigger the standard `save_post` hook in the same way as manual edits, which is why the custom actions aren't firing anymore.

A better approach would be to use WPML-specific hooks that are triggered during the translation process. One particularly useful hook is `wpml_pro_translation_completed`. This hook fires when an automatic translation is completed, allowing us to run any custom actions needed for translated posts.

Here’s a quick example of how we can use it:

add_action( 'wpml_pro_translation_completed', function( $post_id ) {
    // Custom action for translated posts
});

If the goal is to catch updates to translated posts in general, another option is `wpml_sync_duplicate_content`, depending on your specific setup.

While custom coding falls outside the scope of our Support Policy, we always strive to provide recommendations to guide you in the right direction.

Thank you for your patience. It allowed me to double-check this advice with another member of our team to ensure it is the best recommendation for your case.

I hope that you will find all this information helpful.

Mihai Apetrei

February 26, 2025 at 7:52 am #16749379

ghledisC

I tried to use the hook, but it gave me a fatal error and now the post I tried it with keeps on saying translation is in progress, like as if it would be still under automatic translation. Is there a way for me to cancel the translation, so I can retry?

Edit: never mind, I found where I can cancel the jobs. Can you please point me to the documentation of this hook, I don't seem to find it in the Hooks reference.

February 26, 2025 at 8:31 am #16749634

ghledisC

Also I need assistance on resetting WPML, as it seems any translation I try now automatically, it keeps translating forever and never finishes. I removed the code I tried.

February 26, 2025 at 10:51 am #16750460

ghledisC

I managed to resolve my problem with your help, thank you.