Skip Navigation

[Resolved] Toolset and WPML Front end translation

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

This topic contains 11 replies, has 2 voices.

Last updated by Luo Yang 6 years, 2 months ago.

Assisted by: Luo Yang.

Author
Posts
#1093923
foto2_toolset.jpg
foto1_toolset.jpg

I have an active website hidden link where the user can create and edit house properties via front end.
When I created, after some changes in functions.php all works good.
I used the follow code:
add_action('cred_save_data', 'change_post_status',10,2);
function change_post_status($post_id, $form_data) {

if ($form_data['id']==1062 /*That's my edit cred form*/){
$my_post['ID'] = $post_id;
$my_post['post_status'] = $_REQUEST['my_post_status'];
// Update the post into the database
wp_update_post( $my_post );
}
}

function func_get_post_status() {

$post_id = $_GET['_id'];
$x = get_post_status($post_id);
return '<input type="hidden" id="sel_post_status_value" name="sel_post_status_value" value="'.$x.'" />';

}
add_shortcode( 'get_current_post_status', 'func_get_post_status');

/**
*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']==768 /*That's my cred form which creates properties*/){

// Use new WPML API
do_action( 'wpml_admin_make_post_duplicates', $post_id ) ;
}
}
add_action( 'cred_save_data', 'quick_duplicate_save_data_action', 10, 2 );

All that code was added to functions with technical support help.

In edit properties cred form I have an jquery code to obtain x, but now that code appears black (as not active).

Two or three weeks ago, after some toolset and wpml update, when I edit a default language property, all the translated properties join to this turns into default language.

I added two photos. When you enter with user and password, you can see all properties list (foto1) and view or edit all the properties (foto2).

Before plugin updates, after creates a new propertie, my user just have to change menu language and edit.
Now my problem is that is they edit default language and save, all the translations disappears and the translated post turns into default language.

Can you help me?

#1094604

Hello,

Thanks for the details, I can login your website,
Since you did not point out the problem page URL and form URL, I have tried below steps in your website:
1) I assume we are talking about the Toolset form "Afegir propietats"
hidden link

2) create a new page, and put above form into the content:
hidden link

3) Test it in front-end
hidden link

Fill the form, and submit it, I get a new property post:
hidden link
And the other language version, for example:
hidden link
hidden link
hidden link

It seems works fine, there isn't the problem you mentioned above:

Now my problem is that is they edit default language and save, all the translations disappears and the translated post turns into default language.

Can you confirm it? If the problem still persists, please describe detail steps to duplicate the same problem,

Same as above, for your another question:
In edit properties cred form I have an jquery code to obtain x, but now that code appears black (as not active).
Where and how can I see the problem, please provide detail steps, thanks

#1094783

Hi!
Thanks in advance,
The first part (create new projects) it works for me too.

Now my problem is that is they edit default language and save, all the translations disappears and the translated post turns into default language.
The problem still persists. If you take test in default language and edit "descripció" (is description in catalan) then all the language are overwrited.
Steps: 1) Take test in catalan-> Edit-> Write something in descripció.
2) Change language, for example Spanish-> Edit same post-> Write another thing.
3) Return to default language-> Take test and change the descripció text.
4) If you return to Spanish, you'll see now all text is the step 3 text.
Before plugins update, you can put different text in different languages.....and when you edit default language not overwrite all the other languages.

In edit properties cred form I have an jquery code to obtain x, but now that code appears black (as not active).
If you go to Toolset->Views->Editar propietats (id:1065) you'll find the view who insert the cred form Editar propietats (id:1062). Inside this form you'll find JS editor where it is jquery, but now is black and escape all the code.

#1095614

Q1) I have tried to follow your steps, please correct me if there is anything missing:
1) Edit the "test" post in Català language
hidden link

Fill below text in post content:
patata Catala

2) Edit the "test" post in Spanish
hidden link

Fill below text in post content:
patata Spanish

3) Repeat step 1)
I can see it works fine: I can put different text in different languages, see the results:
hidden link
It display the correct text: patata Catala
hidden link
It display the correct text: patata Spanish

Q2) It is a known bug, which should be fixed in the next version of Toolset form plugin, currently, you can try the hot-fix here:
https://toolset.com/errata/quotes-in-the-extra-css-or-js-content-will-get-backslashed/

#1095658

Hi!

Q1) In step 3) you don't have to repeat step 1).
What i'll want you to do it is, edit test in catalan and write another word, for example: patata2.
Then, in Spanish will appear patata2. Default language overwrite all the other languages.
Before plugin updates, i could translate separately, not duplicate.
In the example you're using the same word, then you don't see the problem.

Q2) After make that change, i can't see no quotes, but code still appears with black color, as it won't works. That's normal?
I think possible problem for Q1) could be that code doesn't work good.

#1095678

Please have a look at your own website:
1) open below Catala post, click save button "Actualitza"
hidden link

There isn't the problem you mentioned above: Default language overwrite all the other languages.
See the "test" post in Spanish:
hidden link
The text in content is "patata Spanish", which is different from

Can you confirm it? thanks

2) You are using wrong JS codes, so it doesn't work, you can modify it as below:

jQuery(document).ready(function($){
	var x = $("#sel_post_status_value").val(); 
	$("select[name='my_post_status'] option[value="+x+"").attr('selected', 'selected');
});

And test again, more help:
hidden link

#1095683

1)Can you make one last test, and you'll see what i'm telling you.
Go to the propiety: BAIX EMPORDÀ, CELRA, PISUS, edit in Catalan and change PISUS for PIS or change any part of Description. Then you'll see overwrite that changes in all languages.
I can see in test example, the problem doesn't appears but in old ones, if you edit default language post in front end it will overwrite all the other languages.

2) I make the change you tell me, but the code is still black.

#1095696

1) Since you did not point out the problem post, I have tested below one:
hidden link

Please have a look at above URL, in section "Translations", all other languages version are in "duplicate" status, it conduct the problem you mentioned above: Default language overwrite all the other languages.

In your case, you need to edit each of them, for example:
hidden link

Click button "Edit independently", and test again

See WPML document:
https://wpml.org/documentation/translating-your-contents/displaying-untranslated-content-on-pages-in-secondary-languages/using-content-duplication/

2) All codes in the JS Editor are in black, you can test the same JS codes in other Toolset form.

#1095774

The problem is before plugins update (WPML and Toolset), with the code that I show you in first post, it will translate independently after create new propriety and now it doesn't do it. My client didn't to enter to change propriety from duplicate to edit independently.
That's the real problem.
There is a new way to transform duplicate posts to independent posts after create new propriety and duplicate posts?

#1096814

According to WPML document, there isn't built-in option to bulk "transform duplicate posts to independent posts".

But it is possible with some custom codes, see the similar thread in WPML forum:
https://wpml.org/forums/topic/bulk-converting-duplicate-in-translate-independently/#post-1221361

#1096823

I don't want bulk transformation to duplicate posts to independent posts. I had a website backup and i will install the database with the translated languages.
I need the new post created with cred from (properties), it automatically change post status from duplicate to independent translate. For that we have the code to change post status.

add_action('cred_save_data', 'change_post_status',10,2);
function change_post_status($post_id, $form_data) {

if ($form_data['id']==1062 /*That's my edit cred form*/){
$my_post['ID'] = $post_id;
$my_post['post_status'] = $_REQUEST['my_post_status'];
// Update the post into the database
wp_update_post( $my_post );
}
}

That happens before update plugins.
That's because my user doesn't enter to admin. He works all frontend. And each time they enter a new propertie, I will have to know they have enter a new propertie and i will have to change duplicate translate to independent translate. And it isn't possible or easy way to work.

#1096891

It needs custom codes, I suggest you try these:
when user submit the Toolset form for creating "Propietat" post, remove the "duplicate" relationship in posts of other language version, for example, modify your PHP codes from:

function quick_duplicate_save_data_action( $post_id, $form_data ){

// Change your CRED Form "ID" accordingly below
if ($form_data['id']==768 /*That's my cred form which creates properties*/){

// Use new WPML API
do_action( 'wpml_admin_make_post_duplicates', $post_id ) ;
}
}
add_action( 'cred_save_data', 'quick_duplicate_save_data_action', 10, 2 );

To:

function quick_duplicate_save_data_action( $post_id, $form_data ){
    global $post, $sitepress, $iclTranslationManagement;
        // Change your CRED Form "ID" accordingly below
        if ($form_data['id']==768){
            // Use new WPML API   
            do_action( 'wpml_admin_make_post_duplicates', $post_id ) ; 
			
  			$post_type = 'propietat';
			$trid  = $sitepress->get_element_trid( $post_id, 'post_' . $post_type );
			$translations = $sitepress->get_element_translations( $trid, 'post_' . $post_type );
			
         	// translate versions independently
         	foreach ( $translations as $tr ) {
				delete_post_meta( $tr->element_id, '_icl_lang_duplicate_of' );
        	}
        }      
}    
add_action( 'cred_save_data', 'quick_duplicate_save_data_action', 10, 2 );