Skip Navigation

[Resolved] CRED and WPML – add product that appears as translated

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

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

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 -
- 13:00 – 18:00 13:00 – 18:00 13:00 – 18:00 14:00 – 18:00 13:00 – 18:00 -

Supporter timezone: America/Jamaica (GMT-05:00)

This topic contains 7 replies, has 3 voices.

Last updated by Shane 5 years, 5 months ago.

Assisted by: Shane.

Author
Posts
#1135718

Hello,
my site is in English and German /en /de

German-speaking users visit the form page via /de/form.
english-speaking users via /en/form

At the moment when a German-speaking user adds a new product through the German form (/de/form), a German product is created in the WordPress admin.

I'd like to avoid that. Even though the user is German the product he adds should still occur under English products in the WordPress admin and appear as a product that appears as translated.

How can I do that?

Please help.

Regards,
Nick

#1136016

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hello. Thank you for contacting the Toolset support.

Well - I would like to know here what is your default language?

What if you try to use WPML hook "wpml_make_post_duplicates".

For example try to add following code to your current theme's functions.php file:

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

Where:
- Replace 9999 with your original form Id.

More info:
https://wpml.org/wpml-hook/wpml_make_post_duplicates/

#1136030

Hello Minesh.

My default language is english.

Well actually I'd like to avoid the creation of duplicate content. The product should only be sumbitted in english, regardless of the sites language/subdirectory.

Do you know what I mean?

#1136314
Screen Shot 2018-10-30 at 12.05.16 AM.png

So the product should only appear as translated. And it shouldn't matter where the product was submitted whether it was on the /de or /en the user should browse the site in his language, however, all products he submits should only appear as translated even though they have been saved in English in the WP admin.

#1136989

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Nicholas,

Could you try this hook?


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']==9999){
            $set_language_args = array(
            'element_id'    => $post_id,
            'language_code'   => 'en',
        );
        do_action( 'wpml_set_element_language_details', $set_language_args );
}
}

Could you try this and let me know.

Thanks,
Shane

#1137413

This just results in an error when submitting the form.

Adding this code will show a popup with that message when I try to submit the form.

#1137415

And in the admin there was an auto-draft created.

#1137801

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Nicholas,

Would you mind allowing me to have admin access to your site as well as the page where the form is so that I can perform some testing on this ?

Thanks,
Shane

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.