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?
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.
We use cookies to optimize our website and services. Your consent allows us to process data such as browsing behavior. Not consenting may affect some features.
Functional
Always active
Required for our website to operate and communicate correctly.
Preferences
The technical storage or access is necessary for the legitimate purpose of storing preferences that are not requested by the subscriber or user.
Statistics
We use these to analyze the statistics of our site. Collected information is completely anonymous.The technical storage or access that is used exclusively for anonymous statistical purposes. Without a subpoena, voluntary compliance on the part of your Internet Service Provider, or additional records from a third party, information stored or retrieved for this purpose alone cannot usually be used to identify you.
Marketing
These cookies track your browsing to provide ads relevant to you.