Skip Navigation

[Résolu] Custom field – edit in original language doesn't update value in the translation

This support ticket is created Il y a 6 années et 8 mois. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Aucun de nos assistants n'est disponible aujourd'hui sur le forum Jeu d'outils. Veuillez créer un ticket, et nous nous le traiterons dès notre prochaine connexion. Merci de votre compréhension.

Sun Mon Tue Wed Thu Fri Sat
- 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 -
- 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 -

Supporter timezone: Europe/London (GMT+00:00)

Ce sujet contient 7 réponses, a 2 voix.

Dernière mise à jour par Nigel Il y a 6 années et 8 mois.

Assisté par: Nigel.

Auteur
Publications
#627616

I have added a custom field called "Mileage".

When using the CRED form to update the value, it saves the new value in the original language version.
lien caché

But on the translated version it doesn't update.
lien caché

Incidentally, if I were to THEN update the "description" field of the original language version, the description AND the correct mileage number gets updated on the translated version.

#627791

Nigel
Supporter

Les langues: Anglais (English ) Espagnol (Español )

Fuseau horaire: Europe/London (GMT+00:00)

Hi Paul

Before I try and reproduce this can you tell me what your WPML settings are for the post type in question and the custom field in question?

Go to WPML > Translation Management > Multilingual Content Setup and check the post type and custom field settings.

#628157

wpcf-mileage is set to "Copy" but it obviously doesn't copy.

lien caché

fwiw I had a similar issue with the "Feature Image" not being copied to the translation version when an Ad was posted.
Your support staff Minesh solved by adding this:

add_action('cred_save_data', 'my_save_data_action',10,2);
function my_save_data_action($post_id, $form_data){
  // if a specific form
  if ($form_data['id']==6350){
       
       do_action( 'wpml_make_post_duplicates', $post_id );            
  }
}
#628399

Nigel
Supporter

Les langues: Anglais (English ) Espagnol (Español )

Fuseau horaire: Europe/London (GMT+00:00)

Hi Paul

I'm not sure that code is very helpful when editing posts rather than creating them.

I set up a test site locally and can see that when I edit the post in the backend the updated custom field is copied to the translated post, but if I do the same with a CRED form it is not.

I'm escalating this so it can be investigated further to check whether we have a bug or a missing feature here, and to see if there is a solution I can give to work now.

I'll keep you posted.

#629909

Any update on this issue?
It's my highest priority ToolSet support issue currently.

#629918

Nigel
Supporter

Les langues: Anglais (English ) Espagnol (Español )

Fuseau horaire: Europe/London (GMT+00:00)

Hi Paul

I have just been discussing it with colleagues. It looks like the WPML API has been updated. It is recommended you include the following with the cred_save_data hook, much like your example code above:

        do_action( 'wpml_sync_all_custom_fields', $post_id );

It has not yet been decided whether this should happen automatically within CRED, in case there are circumstances where a user would not want it to happen.

#629931

Is the function "wpml_sync_all_custom_fields" already part of WPML?

Or is it something I am supposed to create?

#629932

Nigel
Supporter

Les langues: Anglais (English ) Espagnol (Español )

Fuseau horaire: Europe/London (GMT+00:00)

I understand it is a recent addition to the WPML API so if you have the current version it should be available.

Use it the same way you described here: https://toolset.com/forums/topic/custom-field-edit-in-original-language-doesnt-update-value-in-the-translation/#post-628157

If you find it doesn't work let me know. I haven't tested it because my colleague said he already had.