Skip Navigation

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

This support ticket is created 6 years, 9 months ago. 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.

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)

This topic contains 7 replies, has 2 voices.

Last updated by Nigel 6 years, 9 months ago.

Assisted by: Nigel.

Author
Posts
#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.
hidden link

But on the translated version it doesn't update.
hidden link

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

Languages: English (English ) Spanish (Español )

Timezone: 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.

hidden link

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

Languages: English (English ) Spanish (Español )

Timezone: 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

Languages: English (English ) Spanish (Español )

Timezone: 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

Languages: English (English ) Spanish (Español )

Timezone: 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.