khromov / wp-wpml-geoip-browser-language-redirect

GeoIP Redirector for WPML (WordPress)

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Redirect based on Geolocation is not working

sneogi-cci opened this issue · comments

Hi @khromov ,

I am using WPML version 4.1.3 on my website. I have installed the wonderful plugin you developed on my website. However, it doesn't seem to work for me. Is it still compatible? Below attached is my setting for the plugin
WPML GEO Redirect ‹ Creative Capsule — WordPress

Hi @khromov,
I'm experiencing the same issue.
Here's what I did:

  1. Activated the plugin
  2. Enabled the "Browser language redirect" option in WPML
  3. Set some language mapping
  4. Trying the redirect on the frontend with chrome plugin TunnelBear VPN

Unfortunately all the countries set in the mapping option are not affected by the plugin

Hi! The app features an extensive debug mode which you can reach by opening the developer console in your browser.

If you post your console logs, we can look into this further.

One important caveat of this plugin is that it redirects the user only once. It's not meant as a way to block users from visiting other languages, just to nudge them in the right direction. So, if you use the same browser when connecting to a VPN, a redirection will already have been performed, and won't be performed again. You can see this in the console log.

Hi @khromov, thanks a lot for your reply.

I have checked the console log on my front end by connecting to Tunnelbear VPN and switching my country to Germany. I don't see any information which relates to the plugin. Also, I am performing this in an Incognito browser so if it was already redirected (which I think it didn't) then again it should have been redirected from a new incognito window.

Hi @sneogi-cci

Seems I'm a bit rusty on the code. You need to edit a line in the main JavaScript file to enable debugging:
https://github.com/khromov/wp-wpml-geoip-browser-language-redirect/blob/master/js/browser-redirect-geoip.js#L3

Change that line to read var GEOIP_DEBUG = true;. If after that you get console errors about console or log not being defined, try removing line 5-18 in that file as well.

It'd be a great feature to be able to toggle debugging mode from the plugin settings page. Possible future improvement.

Same here, I'm using WPML 4.2.8. Did all actions mentioned above and if I check website source code, I can see that plugin is not replacing original WPML browser redirection script, that's why plugin does not have any effect.

Maybe you can check for fix @khromov ? Thanks !

Regarding script replacement, maybe @andreasneuber has some ideas why it wouldn't work?

@khromov found the solution

in wpml-geoip-browser-language-redirect.php file replace 18 line to this
add_action('wp_enqueue_scripts', array(&$this, 'enqueue_scripts'), 100);

and in replace 136 line to this
wp_enqueue_script('wpml-browser-redirect', plugins_url('js/browser-redirect-geoip.js', __FILE__) , array('jquery', 'jquery-cookie'));