• Resolved spmelange

    (@spmelange)


    Hello, we are using your plugin to display certain content based on the location of the visitor.
    Maxmind GeoIP Lite City is used as a data source.
    For example, on https://staging.faircasino.cz/ in the Top promos in November 2024 section, cards are displayed based on the user’s location.
    When using the GTranslate plugin (https://ww.wp.xz.cn/plugins/gtranslate/), the location on translated pages is determined incorrectly.

    Here is what GTranslate support replied about this issue.
    As GTranslate acts as proxy it will show GTranslate IP anyway.
    All the requests to your translated pages are forwarded to your original website.
    When we receive a request from your original server, we translate it and show it to the visitor.
    However we always send the real visitor IP address in X-Real-IP and X-GT-ClientIP request headers.
    You can contact that plugin support and ask to check IPs in those headers and change the logic of how it works correspondingly.

    Is there any solution for this problem?
    Thanks.

    The page I need help with: [log in to see the link]

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Benjamin Pick

    (@benjaminpick)

    add_filter('geoip_detect2_client_ip', function($ip) {
    if (isset($_REQUEST['X-Real-IP']) && geoip_detect_is_ip($_REQUEST['X-Real-IP']) ) {
    return geoip_detect_normalize_ip($_REQUEST['X-Real-IP']);
    }
    return $ip;
    });

    Add this code to your theme’s function.php or similar. Does this work for you?

    Caveat: other clients will be able to easily forge this header. That’s why there is a whitelist for reverse proxies – do you know the IP range of the GTranslate servers?

    Thread Starter spmelange

    (@spmelange)

    Hello, since we haven’t heard back from you for a long time we have decided to stop using GTranslate.
    Thank you for the proposed solution, if we go back to using GTranslate, we will check it out.
    We do not know the IP address range of the GTranslate servers.

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Problem with determining location when using GTranslate’ is closed to new replies.