Skip to content Skip to sidebar

This is the technical support forum for WPML - the multilingual WordPress plugin.

Everyone can read, but only WPML clients can post here. WPML team is replying on the forum 6 days per week, 22 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 14:00 9:00 – 14:00 9:00 – 14:00 9:00 – 14:00 9:00 – 14:00 -
- 15:00 – 18:00 15:00 – 18:00 15:00 – 18:00 15:00 – 18:00 15:00 – 18:00 -

Supporter timezone: Asia/Dhaka (GMT+06:00)

This topic contains 1 reply, has 2 voices.

Last updated by Prosenjit Barman 9 months ago.

Assisted by: Prosenjit Barman.

Author Posts
October 18, 2024 at 7:42 am #16302981

xeniaC

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?

October 21, 2024 at 8:15 am #16310758

Prosenjit Barman
WPML Supporter since 03/2023

Languages: English (English )

Timezone: Asia/Dhaka (GMT+06:00)

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.

While writing custom code is a bit outside our scope, we can only provide suggestions and helpful starting points:
- Gravity Forms: Use the `hidden link">gform_after_submission` hook.
- WPML: Use the `wpml_set_element_language_details` function.

I hope this gives you a clear direction, and I hope it will solve your issue! 😊

If you need any additional guidance or have any other queries, feel free to reach out!

Best regards,
Prosenjit

The topic ‘[Closed] Setting language of new post through Gravity Forms’ is closed to new replies.