GeoIP addon is not working for my region/state

2 years 9 months ago #72325

Dan Oldermount's Avatar Dan Oldermount

I have several modules on the same position, and with RL-Advanced Modules Pro and GeoIP add-on I have configured each module to be published only when on a particular region/state. On backend, the states of my country do appear, but on frontend all modules are displaying instead of only the one for my location.

I've tried to echo my current state using custom PHP with Sourcerer, using this code:

require_once JPATH_LIBRARIES . '/geoip/geoip.php';
$geo = new GeoIp($ip);
$location = $geo->get();
echo $location->state;

and with "region" as variable, too
echo $location->region;

but both codes return null.

I've tried both over wi-fi and 4G mobile network.

Please advise on how to take advantage of your solution. I'm at Monterrey, Nuevo León, México, by the way.


2 years 9 months ago #72327

Peter van Westen's Avatar Peter van Westen Admin

You are passing $ip which is not set. Just pass nothing so that GeoIP will get your current ip:

$geo = new GeoIp;