Skip Navigation

Custom fields set to “Copy from original to translation” by WPML are not copied when you use CRED to edit the fields

Resolved

Reported for: Toolset Forms 1.9.5

Resolved in: 2.5.5

Topic Tags: CRED API, Toolset Forms

Symptoms

When you use Types and WPML, you can set custom fields as translatable or be copied once/always into translations.

When you use CRED to edit posts in original language these settings are not respected, the custom field is not copied over to the translation even if set so on the Toolset -> Post Fields page.

Workaround

The current workaround is to use a custom code snippet hooking into CRED and WPML API.

For example, let’s assume you have a custom Single Line field that is set to be always copied to translation, and your CRED Form that edits a Post that has an ID of 3.

Put the following code into your theme’s functions.php file (make sure to adapt the code to your case and usage scenario):

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']==3)
    {
        do_action( 'wpml_sync_all_custom_fields', $post_id );
    }
}

Comments are closed