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
#523992

Hello,

I have created the post type "provider". When a new post is created in English then automatically it is duplicated in the other languages with the use of

do_action( 'wpml_admin_make_post_duplicates', $post_id ) ; 

Now all the languages are synchronized and for a while all of them have english content. Then I let the users to edit the post in their language and everything till now works perfect. Each language has the correct content.

The issue is that the posts remain synchronized and if a user updates the post in English through a cred form then the changes in all the other languages are lost and everything appears in English again. If I edit the translation from the wordpress dashboard the posts are unsynchronized and evrything works properly. But that does not happen if the post is edited through a cred form.

Is there a way to unsynchronize the posts after their creation? So if the english post is updated through a cred form it will not influence the content in the other languages. I wish that it is possible beacause it's a very big issue..

Thank you!

#524125

Dear ioannis,

The problem you mentioned above is abnormal:
The issue is that the posts remain synchronized and if a user updates the post in English through a cred form then the changes in all the other languages are lost.

Please try this:
1) Deactivate other plugins and switch to wordpress default theme, and test again.
2) If the problem still persists, please provide a copy of your website, also point out the problem URL, I need to test and debug it in my localhost.

#525010

There are 20 plugins in your website, I need your permission to deactivate them and switch theme, please backup your website first. thanks

#525038

Yes, of course Luo! It's a copy from the original site. Feel free to do anything that is needed.

The code that duplicates the post from the original language to the translation is here:
hidden link
I have copied that code to functions.php file of the twenty seventeen theme in case you need to deactivate the "code snippets" plugin.

Thank you!

#525518

OK, I am checking it in your website, will feedback if there is anything found

#525536

Since it is a custom codes problem, I need to edit the codes in theme/functions.php, but the FTP access you provided above is not valid, I get this error message:
Command: USER Maria
Response: 331 Password required for Maria
Command: PASS ****************
Response: 530 Login incorrect.
Error: Critical error: Could not connect to server

Please check it. thanks

#525669

I am sorry Luo,

I am not developer and I did a mistake to the ftp adress I gave you. The right ftp adress is

hidden link

Please replace the "mydomain" part of the adress with the name of my domain

I have also changed the password in case it was wrong. You can login using the same password that you use to login to my worpress dashboard

I am sorry about the inconvenience and thank you for your support!

#526030

I have tested both passwords and the FTP address you mentioned above, same problem:
Response: 530 Login incorrect.
Error: Critical error: Could not connect to server

Please check it, and in the same time, I will check it without FTP access, will update this thread if there is anything found.

#526121

Hello Luo,

the text editor automatically added a http:// before the ftp address I wrote in my previous response. I just checked if it is possible to login through Filezilla and I succesfully logged in with these credentials:

ftp . my domain .gr/test2

I added the gaps so the editor cannot add again the http:// before the ftp address. Please erase the gaps between the words and replace the "my domain" part of the address with my website's name.
Username: The username that you use to login in my wordpress site
Password: The password that you use to login in my wordpress site. It begins with jT..... and it ends with ..............N*f

You can find the password in this post:
https://toolset.com/forums/topic/cred-wpml-issue/#post-524975

If it is not possible to login please open the private form so I can give you the username and password again

Thank you

#526857

I test again, the FTP access, it is not valid, anyway, I can debug the codes without the FTP access.
I assume we are talking about this case:
1) Open URL:
hidden link

2) Submit the CRED form, I see the CRED form is submitted successful,

3) Refresh the problem posts:
hidden link
And
hidden link
I can see both posts display same post title and post content.

You are going to achieve this:
after submit the CRED form, do not change the post in other languages:
hidden link

If it is, I have modified the PHP codes from:

wp_update_post( array( 'ID' => $post_id ) ); // Update the post to sync the meta data to the translations
        }      

To:

//wp_update_post( array( 'ID' => $post_id ) ); // Update the post to sync the meta data to the translations
        }      

Please check if it is fixed, thanks

#526895

Dear Luo,

I don't know what is happening with the ftp connection, indeed I tried to login and it was impossible although 2 days ago I was able to login normally. Anyway I have changed the password to Bpiv!851 and now everything is ok. I just succesfully logged in through filezilla

Have you made other change except commenting the following code?

//wp_update_post( array( 'ID' => $post_id ) ); // Update the post to sync the meta data to the translations

at
hidden link

Now if I edit Maria's Profile everything works properly, no duplicate in the other language. But if I create a new profile again the same problem. Here is the url:
hidden link

How could I fix this?

Thank you!

#527042

No, I have not change any other codes in your website.

I am check the new problem URL, will feedback if there is anything found

#527280

What do you mean this:
But if I create a new profile again the same problem.

I assume we are talking about this problem with below steps:
1) Create a "Massage Therapists" post with CRED form "Create Profile" in URL:
hidden link
2) With the custom codes you mentioned above:

/**
  *Duplicate Content on submit of Original to all secondary langs (for translation)
  */
function quick_duplicate_save_data_action( $post_id, $form_data ){
    
        // Change your CRED Form "ID" accordingly below
        if ($form_data['id']==58){
  
            // Use new WPML API   
            do_action( 'wpml_admin_make_post_duplicates', $post_id ) ; 
		  //wp_update_post( array( 'ID' => $post_id ) ); // Update the post to sync the meta data to the translations
        }      
}    
add_action( 'cred_save_data', 'quick_duplicate_save_data_action', 10, 2 );

It will be able to duplicate the posts to all secondary languages.

If you do not want to duplicate the posts to all secondary languages, just remove above codes. It will create only one post with the CRED form.

#527323

Hello Luo,

till now it was possible with the above code to duplicate the post and then edit it in each language separately without affecting the translation. This way the providers were able to translate their profiles. It is expected behaviour that this is not happening any more? And if I cannot use the above code is there any other way to allow frontend translation? It is very important for the functionality of my website.

#527352

You are using the CRED action hook "cred_save_data" to trigger your custom function, and you have already specific the CRED form ID 58 in the custom PHP function, that means it will only wors when your user is using the CRED form "Create Profile" to create a "Massage Therapists" post, then the custom codes will duplicate the post to all secondary languages. It will not occur when your user use other CRED form to edit the post.

I assume you are going to achieve this:
1) When user is creating a "Massage Therapists" post with CRED form 58, duplicate to all secondary languages
2) When user is editing a "Massage Therapists" post with other CRED form, only take effect on this "Massage Therapists" post.
And it does work as expected, can you confirm it?