Dear Luo,
this is exactly what I am trying to achieve but number 2) is not working as expected. My custom function should work only for the form 58 that creates the post. But when a user edits the post with another CRED form only the content of the post in current language should be affected. The issue is that this does not happen... the post content is duplicated from english to the translated post. Propably there is a bug. Till some days ago everything was working properly, I do not know what has changed.
When I tried to debug in your website, I get PHP 500 error, since the FTP access is not valid in my side, please provide a database dump file of your website in below private detail box, I need to test and debug it in my localhost, thanks
The new FTP access is using username "m****", which is lower case, it is different from the FTP access you provided in post, which is upper case "M*****":
https://toolset.com/forums/topic/cred-wpml-issue/#post-524975
It does work, and I can login with the FTP access, and I am checking it in your website, will feedback if there is anything found
I have added below codes into your theme(twentyseventeen) functions.php:
add_action('cred_before_save_data', 'not_sync_post_func',10,1);
function not_sync_post_func($form_data)
{
// if a specific form
if ($form_data['id']==66)
{
global $sitepress;
if(isset($form_data['container_id'])){
$post_id = $form_data['container_id'];
$trid = $sitepress->get_element_trid( $post_id, 'post_' . $post->post_type );
$translations = $sitepress->get_element_translations( $trid, 'post_' . $post->post_type );
foreach ( $translations as $tr ) {
if ( $tr->element_id != $post_id ) {
delete_post_meta( $tr->element_id, '_icl_lang_duplicate_of' );
}
}
}
}
}
Please test again, check if it is what you want.
More help:
cred_before_save_data
https://toolset.com/documentation/programmer-reference/cred-api/#cbsd
This hook allows doing a custom action right before saving or processing any data but after validation.
Luo, I seriously don't know how to thank you, You are my hero. You saved me one more time!!!
Just for the history what was happening was a bug or expected behaviour? If it was a bug do we know what was causing it?
No, it is not a bug, but a expected behaviour, since you are using WPML action wpml_admin_make_post_duplicates to duplicate a post into other language, all duplicated posts will sync the settings from the post.
I see, thank you again Luo for your so good support!!!!!