Fetching country from IP using wordpress plugin GeoIP detection?


Staff member
I've installed this plugin: <a href="https://tah.wordpress.org/plugins/geoip-detect/" rel="nofollow noreferrer">https://tah.wordpress.org/plugins/geoip-detect/</a>

The plugin seems to work fine when I test "lookup" within the plugin, it returns my geo-information.
However when I try to implement code within one of my wordpress pages it doesn't work.

$userInfo = geoip_detect2_get_info_from_current_ip($ip);
echo $userInfo-&gt;country-&gt;name;

I'm calling the function from a native woocommerce page where single-products are shown.
But the fucntion returns nothing.
Do I have to include anything more to call the function <a href="https://github.com/yellowtree/wp-geoip-detect/wiki/API-Usage-Examples" rel="nofollow noreferrer">geoip_detect2_get_info_from_current_ip()</a>?

I also tried:

&lt;?php echo do_shortcode("[geoip_detect2 property='country']"); ?&gt;

It doesn't return anything either.
I'm doing the editing within godaddy's code editing tool, so I might be missing errors.