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.
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 );
}
}
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.
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.
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 );
}
}