Skip Navigation

[Resolved] Cred & WPML Issue

This support ticket is created 7 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.

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

Supporter timezone: Asia/Hong_Kong (GMT+08:00)

Tagged: 

This topic contains 21 replies, has 2 voices.

Last updated by ioannisM-2 7 years, 5 months ago.

Assisted by: Luo Yang.

Author
Posts
#527363

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.

#527390

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

#527739

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

#527768

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.

#527789

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?

#527795

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.

#527953

I see, thank you again Luo for your so good support!!!!!