Skip to content
Advertisement

redirect the users based on their ip to a language every time they visit my website with the ability to switch lang after redirection?

I have a WordPress site using WPML for Multilang, I have three languages on the site with subdirectories option ( /fr , /en , /de ).

Example: If a user is in Germany I want to redirect him to “/de” and still give him the ability to switch to another language

I found some plugins like “IP2Location” but all plugins like that keep redirecting the user to his current country language and never be able to switch to another language

I tried doing it with javascript by applying cookies but that have a problem too it will redirect users once a day and not every time they come back to the site

Advertisement

Answer

Here is the best solution for it. You can try it now it will be work. Just replace your country code and website url.

JavaScript
User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement