Skip Navigation

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

Problem:
The client has enabled the Browser language redirect functionality with the setting "Redirect visitors based on browser language only if translations exist". However, they are experiencing issues as the site does not redirect to the Polish version when accessing the homepage with the browser language set to Polish.
Solution:
We explained that WPML performs the language redirect only once to allow visitors the option to switch languages manually. If WPML were to redirect to the browser's language every time, it would prevent users from choosing a different language after being redirected. We recommended checking the browser's cookies or using an incognito window to test the redirect again. Additionally, we provided a guide for further assistance:
Automatic redirect based on browser language
If the client needs to customize the behavior further, we suggested consulting our hooks reference:
WPML Hooks Reference
If the provided solution is not relevant due to being outdated or not applicable to the client's case, we recommend opening a new support ticket. We also highly suggest checking related known issues at https://wpml.org/known-issues/, verifying the version of the permanent fix, and confirming that the latest versions of themes and plugins are installed. If further assistance is needed, please contact us through the WPML support forum.

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 5 replies, has 2 voices.

Last updated by Osama Mersal 1 year, 1 month ago.

Assisted by: Osama Mersal.

Author Posts
March 9, 2024 at 9:40 pm #15392000

dominikC-4

Hi
We've enabled the Browser language redirect functionality and set it to "Redirect visitors based on browser language only if translations exist". Unofortunatelly it looks like it doesn't work.

The home page of our site wptest.taalhammer.com has the Polish version.
I've set my language in the browser Chrome as Polish (only one language).

When I type in browser url wptest.taalhammer.com I expect it would redirect me to wptest.taalhammer..com/pl/ but nothing happens
Please help

March 10, 2024 at 9:31 am #15392315

Osama Mersal
WPML Supporter since 02/2020

Languages: English (English ) Arabic (العربية )

Timezone: Africa/Cairo (GMT+03:00)

Hi,

Thanks for contacting WPML forums support. I'll be glad to help you today.

Could you please check if the issue persists in a minimal environment by following these steps?

1- Deactivate all the plugins except WPML CMS and String Translation.
2- Switch to a WordPress default theme like Twenty Twenty-one.

If the issue is gone, activate them one by one to see which one is causing an interaction issue.

❌ Please backup your database before performing the above test ❌

Best regards,
Osama

March 10, 2024 at 11:21 am #15392466

dominikC-4

ok, looks liek it works but it does the redirect only the first time the user enters the website. Is it intended behaviour?

March 10, 2024 at 11:24 am #15392469

Osama Mersal
WPML Supporter since 02/2020

Languages: English (English ) Arabic (العربية )

Timezone: Africa/Cairo (GMT+03:00)

Hi,

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.

Please check this guide. (https://wpml.org/documentation/getting-started-guide/language-setup/automatic-redirect-based-on-browser-language/)

Best regards,
Osama

March 10, 2024 at 1:31 pm #15392607

dominikC-4

OK, clear. Is there a hook that we could use to catch this event and/or when user changes the language with language switcher?

March 10, 2024 at 2:24 pm #15392626

Osama Mersal
WPML Supporter since 02/2020

Languages: English (English ) Arabic (العربية )

Timezone: Africa/Cairo (GMT+03:00)

Hi,

I'm not sure if there is a hook like this. Please check our hooks Reference. (https://wpml.org/documentation/support/wpml-coding-api/wpml-hooks-reference/)

Best regards,
Osama