• The plugin is great but I noticed that on the home page the function geoip_detect2_get_info_from_current_ip doesn’t work.

    What could be the reason for that?

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

    (@benjaminpick)

    It should work.

    Are you using shortcodes or PHP syntax? What does the function return?

    Thread Starter ivanyosifov

    (@ivanyosifov)

    if (function_exists('geoip_detect2_get_info_from_current_ip')){
      $userInfo = geoip_detect2_get_info_from_current_ip();
      $countryCode = $userInfo->country->isoCode;
    }

    This code is in the header.php. Doesn’t even enter the if block. Without the if block we get error – function doesn’t exist.
    The weird thing is that it works on any other page.

    Plugin Author Benjamin Pick

    (@benjaminpick)

    This is before plugins_loaded then. Try to wrap it in

    add_action(‘plugins_loaded’, function() { … });

    (What do you want to add in the header.php? Maybe body class is a possibility for you?)

    • This reply was modified 10 months, 2 weeks ago by Benjamin Pick.
    Thread Starter ivanyosifov

    (@ivanyosifov)

    Hello again Benjamin,

    Turns out we are using Plugin Organizer and for some reason the Geo IP Detection plugin was turned off for the home page. That’s why the home page wasn’t recognizing the geoip_detect2_get_info_from_current_ip.

    So it’s fixed now. Thank you for the quick support.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Home page doesn’t detect geoip_detect2_get_info_from_current_ip’ is closed to new replies.