(Preferably Beda can answer this question because it applies to a solution in one of his previous posts.)
On our site, users can create and edit their listings in a directory through CRED forms. We decided to make it multilingual, so in order to automatically duplicate content created with CRED, we used the solution in this post by Beda:
https://toolset.com/forums/topic/cred-custom-post-type-front-end-translations/#post-344169
It works amazing, except for when the user tries to edit his post in the opposite language of which he created the post in (so if they created it in Chinese and use the edit form when the language is switched to English, and vice-versa). When a user tries to do this, the translation is broken off and gets lost, and no longer works anymore. I suspect this is because the posts are set to "Duplicate" and not "Translate", which normally doesn't let you edit the 2nd language's post (but CRED overrides this)...
#6 in Beda's post says that the duplicate flag should be removed in this situation, but that is not the case with my forms here.
So to recap:
User creates "Listing" in English, Chinese post auto-duplicates -> User visits that listing in Chinese and uses CRED edit form -> After submit, translation relationship gets lost and Chinese post is corrupt.
(and vice-versa, so not dependent on default language)
EDIT: So I corrected the problem of breaking the translation relationship by first using Beda's shortcode to get language code:
/**
*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');
And then inserted it into my CRED form as a value in a solution Caridad mentioned in this post:
https://toolset.com/forums/topic/cred-wpml-post-to-specific-language/#post-278632
<input type="hidden" name="icl_post_language" value="[wpml_language_code_value]" />
So the form will always update with the current language selected. Great
HOWEVER
The "duplicate" flags still remain, meaning even though the user can now edit the post in either language, any changes will be shown in the other language as well, so translation is still not possible.
I found this field while searching WPML here:
https://wpml.org/forums/topic/batch-change-translate-independently/
But I'm not sure what to do with it. I'll check the database. I'm thinking that if this is the right field to update, in the CRED edit form, I can make it an optional field based on whether the user wants to create a separate translation OR keep everything the same across languages.
Please tell me if there's something I missed and could have done in an easier way