Skip Navigation

[Resolved] CRED Custom Post Type Front-End Translations

This thread is resolved. Here is a description of the problem and solution.

Problem:
How to translate Posts with WPML from the Front end using CRED.

Solution (include the steps to follow here):
https://toolset.com/forums/topic/cred-custom-post-type-front-end-translations/#post-344169

This support ticket is created 8 years, 5 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
- - 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00
- - - - - - -

Supporter timezone: Asia/Ho_Chi_Minh (GMT+07:00)

This topic contains 6 replies, has 2 voices.

Last updated by tomasT 8 years, 5 months ago.

Assisted by: Beda.

Author
Posts
#344144

I am trying to: Allow CRED users to make the translation of their posts in the front end.

I visited this URL: https://toolset.com/documentation/user-guides/ and your support forum, but searching there was not succesfull.

I expected to see: An easy way to front-end custom-post translations. "CRED+WPML integration" should have it as a default option. As there is an option to "Edit Content" it should be an option "Add Translation".

Instead, I got: No guides. Don't know where to start from.

Regards!

#344169

Thank you for contacting us here in the Support Forum

Unfortunately, the CRED AddOn that did this, is deprecated due to low usage.

Anyway, I happen to have implemented sort of a front end Translation with CRED + WPML.

1. Create your CRED forms to submit the Content (default language)
2. Use WPML Core and Translation management (active on your install)
3. Add a CRED form that EDIT's the Post type
4. Use WPML API to submit the Form and trigger this API with a CRED API as below instructed:

To apply to the CRED CREATE POST FORM:

/**
  *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']==ID){
 
            // 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 taxonomies must be translated in the backend
- The Post Type must be marked as "Translatable"
- Copy taxonomy to translations in WPML > Translation Management must be set
- After you submit a Content with the CREATE Form the custom code above will DUPLICATE it to all secondary languages.

Then, with the Edit form, you can Edit those duplications (actually, translate :))

To avoid edition of default language content, you can check in a view as example (where you display the content + CRED forms) if the current language viewed is NOT your default language.
You can use this Custom ShortCode to return the current WPML language:

/** 
 *Add ICL_LANGUAGE_CODE shortcode 
 */
        
function wpml_language_code_value_func() {
	$return = ICL_LANGUAGE_CODE;
	return $return;
	}   
add_shortcode('wpml_language_code_value', 'wpml_language_code_value_func');

Use it in a wpv-conditional to evaluate the current language viewed.

This below is how the translation works for your logged in user on the front end:

1. Content must exist in your default language
2. Otherwise create it first in that language
3. Creating new Content in default language will duplicate the Original Post into all secondary langauges
4. You can then head to your preferred language (secondary), locate the duplicated Post and edit it (translate it)
5. If the Post already exists in default language, you can proceed the same way
6. Submitting the "edition" (translation) will automatically remove the duplicate_flag for ALL translations, so your content will NOT be overwrtitten if a translation is edited 🙂
7. All Taxonomies are automatically siynced for you, no worries. Only bare transaltion of Text is needed.
(this is why you need to translate taxonomies first in the WP Backend as a Admin)

I hope I could help with this custom approach.

Please let me know if you need further infos about this.

Thank you for your patience.

#344176

Thank you for so fast answer. I think it will take me some more time. Please don't close this topic.

In our country there are few co-oficial languages. So, there's not a "default" language for every user. I will try it, but I know my customer will not like it.

Anyway, I don't understand why it was deprecated. If users cannot manage multilingual content, I wouldn't say that CRED is fully WPML compatible. WPML and CRED (real web2.0) are your flagship plugins and cannot understand such decission.

Please, Is there something I can do for this AddOn to be restored and active?

Thanks a lot!!!

#344200

Sorry if the question is very simple but, when you say "To apply to the CRED CREATE POST FORM:"; where is the code supposed to be "applied"? in the forms js? in the theme's functions.php?

Another related question: What will happen if the user needs to update the content in default language? all translations will be lost?

For better understand my question. The site is a "Project Market". Where users (entrepreneurs) will post their projects or ideas. They should be able to update their posts, and its translations, after interacting with other users (mentors). For that interaction we use buddypress message system. Even if there's an administrator with a hosting rol; content should be created and maintained by users.

Can it be done with CRED+WPML?

#344333

I apologize the delay here

1. You have a point in your statement that CRED Translation should be somehow re-implemented.
The current problem is, the Plugin is deprecated, and wont work with Toolset and WPML at today's version.

I went ahead and asked DEV if it's possible to re-open that project. I am sure it would have some sort of impact in the community.

2. Default language:
- Either way, WPML (and my above approach) requires a default language.
You can then set up any secondary language you want.

3. The code goes to functions.php, sorry for not having been specific here.

4. You will use a EDIT form to EDIT posts, so the code is not triggered if the Posts are edited.
The code (duplicate to secondary languages) only is fired when the Form with the specific ID is used.

Of course, editions in the original Post are not reflected in the Translated Post, this isn't even the case in WPML.
What you can do here is as example send a notification on edition of Posts to the author, that the Translations needs updates.
I know, it's not the "cream" process 🙁
It's what I can offer you currently being this a custom solution using WPML API and CRED API.
WPML is not intended to be a Front End Translation Software, and CRED (translation) is deprecated, so we have to workaround some things.

If it can be done... Yes, with Custom Code, at the moment.

Unfortunately it's no "out of the box" feature.

For ease, Backend Transition should be used at the moment, if you would prefer this to custom code the solution using our API.

I Apologize this inconveniences.

Please let me know if you need further infos about this, and do not hesitate to open a new thread if other issues or problems arise

Thank you for your patience.

#344410
Captura de pantalla 2015-11-03 a las 1.29.52.png

I think this can work, but I'm trying to do it without success. I will delete all forms and start from scratch.

One question:
For this to work, in WPML Translation Management->Multilingual Content Setup->Custom Posts, what should I check for CRED Form custom Types? (See the screencapture)

Thank you.

#344443

It works, and works fine. Thanks very much!!! 😉

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.