Skip Navigation

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.

This topic contains 1 reply, has 2 voices.

Last updated by Dražen 1 year, 10 months ago.

Assisted by: Dražen.

Author Posts
July 20, 2023 at 8:51 am #14070423

perM-2

Hello,

I have a request to redirect users to a second WPML language based on the browser’s language settings. I enabled this feature in WPML, and it works.

However, after the redirection, when I enter a direct URL to the main language (English), for example the homepage, the redirection doesn’t happen, and the language cookie is changed to English.

We need to stay in the second language even if a direct URL is entered, until someone manually switches the language to English. How can we achieve this?

Also, the minimum timeout for the cookie settings is 24h. Can we change this to 10 min?

Thanks in advance.

Regards,
Erik

July 20, 2023 at 10:59 am #14071509

Dražen
Supporter

Languages: English (English )

Timezone: Europe/Zagreb (GMT+02:00)

Hello Erik,

what you have described is expected and how WPML works.

WPML will do this language redirect only once and then not redirect anymore. We do this to allow visitors to still switch languages. If we always push back to the browser’s language, visitors will not be able to manually switch languages after WPML redirects them to the language set by their browser.

This single-time redirect operation resets every 24 hours or more.

It is not possible what you have described without additional custom coding, also please note search index bots are also some kind of users and issues can happen with the SEO of your page with browser redirects and even worse if you keep pushing users to only one language.

- https://wpml.org/documentation/getting-started-guide/language-setup/automatic-redirect-based-on-browser-language/how-browser-language-redirect-affects-google-indexing/

Another way is to try some additional redirect plugins, we have a few of them on our list, but not sure if they allow what you have described:

- https://wpml.org/plugin/ip2location-redirection/
- https://wpml.org/plugin/geotargetingwp-2/
- https://wpml.org/plugin/wpml-redirect-based-on-ip-country/

Hope this helps.

Regards,
Drazen