Support » Plugin: GeoIP Detection » Picking up incorrect location

  • Hi guys,

    For some reason the incorrect country is now being picked up, it’s worked perfect until this week – I’m assuming it’s because it’s set to update the DB automatically.

    This is what I have, but the body css just pulls in that your location is un the US when my ip is UK based.

    <?php
    $userInfo = geoip_detect2_get_info_from_current_ip();
    if ($userInfo->country->isoCode == ‘US’){
    // United States
    echo ‘(+1) 844 335 1254’;
    } elseif ($userInfo->country->isoCode == ‘AU’){
    // Austrailia
    echo ‘(+61) 1800 45 2335’;
    } elseif ($userInfo->country->isoCode == ‘CA’){
    // Canada
    echo ‘(+1) 855 211 8639’;
    } elseif ($userInfo->country->isoCode == ‘NZ’){
    // New Zealand
    echo ‘(+64) 800 955 010’;
    } else {
    // United Kingdom
    echo ‘(+44) 844 561 7233’;
    }
    ?>

    Thank you

Viewing 3 replies - 1 through 3 (of 3 total)
  • I’m working on this same issue.

    Interestingly, when I’m in the admin back-end and go to Plugins > GeoIP Detection > Lookup and test my public IP address, it correctly returns the country ISO code ‘GB’. But when I visit the front end of my site, it is incorrectly matching the condition $userInfo->country->isoCode == 'US' statement and returning the string within.

    Why might this differing behaviour be occurring? The Disable caching a page that contains a shortcode or API call to geo-dependent functions setting in options is checked.

    For anybody having the same issue arise,

    I had to check “The server is behind a reverse proxy” and add the servers IP address manually and this resolved my issue.

    Thanks!

    Plugin Author Benjamin Pick

    (@benjamin4)

    Yes the reverse proxy needs to be enabled manually for security reasons.

    Is this also the solution for you, @ismunday?

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Picking up incorrect location’ is closed to new replies.