Background of the issue:
I have created a Gravity Form for certain users to upload new posts on the website hidden link. I want the language of the post to be determined through the form so that the post only appears in the corresponding version of the website. The plan is to have a different form corresponding to each language, so the post language is determined by default through the form, not by the user.
Symptoms:
I have not found any documentation directly relevant to setting the language of new posts through Gravity Forms.
Questions:
How can I set the language of a new post through Gravity Forms using WPML?
Is there a way to automatically assign a language to a post based on the form used?
Hi There,
Thanks for contacting WPML Support. Sorry for the delay in responding due to the weekend.
I understand what you're looking for. As far as I know, Gravity Forms doesn't have a built-in feature to set the language for new posts when working with WPML. Therefore, it may require custom coding to achieve what you're looking for.
I have researched a bit and found the `gform_after_submission` hook, which allows you to run custom code after a form is submitted. By combining this with WPML’s `wpml_set_element_language_details` hook, you can automatically assign a language to the post based on the specific form that was used.
The approach is simple:
1. Each form will correspond to a specific language.
2. Using the form ID, you can map it to the language code.
3. When the form is submitted, this custom code will set the post language using WPML's API.