Hello,
Perhaps you’ll remember me as the dingbat who forgot to save the plugin settings before, lol. I swear, this time I checked everything, so here it goes.
I ran into a small snag with the plugin. In the health check I get 2 critical issues dealing with an active PHP session and how it conflicts with the REST API. I don’t have many plugins installed on my site so it was not difficult to pin it down to this one.
At lines 58 and 107, ip2location-variables.php calls session_start()
. After doing some searching, I found that apparently WP doesn’t like sessions being started like this anymore(?)
I managed to “correct the problem” by editing the “offending code” from
if ( !session_id() ) {
session_start();
}
to
if ( !isset( $_SESSION ) {
session_start( [ 'read_and_close' => true ] );
}
Again, BOTH session_start calls had to be changed at lines 58 and 107; I suspect adding the argument to session_start()
is the only thing that is really needed, as I am sure !session_id()
and !isset($_SESSION)
accomplish the same thing.
I just updated the plugin today, when I noticed the critical issues in the Site Health screen. Both WP and the plugin are up to date.
I hope I helped and not broke the plugin or wasted your time with something this silly.
Thanks again for a great (free) plugin.
]]>Please see when i executed these code on a page, this is the result on live website. So visitor data is no where and its gives only my server data which is actually through cloudflare.
I copy codes from the sample you mentioned on your plugin page.
// Detect visitor IP automatically
$data1 = ip2location_get_vars();
$data1 = json_decode($data1);
echo $data1->ipAddress;
echo $data1->countryCode;
echo $data1->countryName
;
$data->cityName
;
echo $_SERVER[‘IP2LOCATION_IP_ADDRESS’];
——————————
Display on page this information when opening the page with above codes, i am based in the middle east.
this is the information xxx i change it.
141.xxx.68.226FRFrance141.xxx.68.226
=============
How to get visitor country Code not my server codes or cloudfare IPs.
]]>Hello,
This plugin, as described, is perfect for my needs. Because on my local machine the IP auto detected was 127.0.0.1, I tried to test it on a development site I have. Unfortunately the plugin seems to not be working, or I am doing something wrong.
The link I provided should send you to the page where I explain the problem in detail.
I have tried deleting the plugin and reinstalling. I updated the BIN file using the plugin settings page and my token, as well as manually uploading the BIN file, (including the IPV6 version).
On my local machine, the plugin works great, but not on my online host.
Thanks for your help.
]]>I’m getting a long list of errors when enabling this plugin. I manually uploaded the DB11LITEBIN file then tried to use the variables. I get no returned results from anything related to the functions:
<?php
$data = ip2location_get_vars();
$data = json_decode($data);
?>
Notice: Trying to get property ‘ipAddress’ of non-object in /wp-content/plugins/ip2location-variables/ip2location-variables.php on line 77
Notice: Trying to get property ‘countryCode’ of non-object in /wp-content/plugins/ip2location-variables/ip2location-variables.php on line 78
Notice: Trying to get property ‘countryName’ of non-object in /wp-content/plugins/ip2location-variables/ip2location-variables.php on line 79
Notice: Trying to get property ‘regionName’ of non-object in /wp-content/plugins/ip2location-variables/ip2location-variables.php on line 80
Notice: Trying to get property ‘cityName’ of non-object in /wp-content/plugins/ip2location-variables/ip2location-variables.php on line 81
Notice: Trying to get property ‘isp’ of non-object in /wp-content/plugins/ip2location-variables/ip2location-variables.php on line 82
Notice: Trying to get property ‘latitude’ of non-object in /wp-content/plugins/ip2location-variables/ip2location-variables.php on line 83
Notice: Trying to get property ‘longitude’ of non-object in /wp-content/plugins/ip2location-variables/ip2location-variables.php on line 84
Notice: Trying to get property ‘domainName’ of non-object in /wp-content/plugins/ip2location-variables/ip2location-variables.php on line 85
Notice: Trying to get property ‘zipCode’ of non-object in /wp-content/plugins/ip2location-variables/ip2location-variables.php on line 86
Notice: Trying to get property ‘timeZone’ of non-object in /wp-content/plugins/ip2location-variables/ip2location-variables.php on line 87
Notice: Trying to get property ‘netSpeed’ of non-object in /wp-content/plugins/ip2location-variables/ip2location-variables.php on line 88
Notice: Trying to get property ‘iddCode’ of non-object in /wp-content/plugins/ip2location-variables/ip2location-variables.php on line 89
Notice: Trying to get property ‘areaCode’ of non-object in /wp-content/plugins/ip2location-variables/ip2location-variables.php on line 90
Notice: Trying to get property ‘weatherStationCode’ of non-object in /wp-content/plugins/ip2location-variables/ip2location-variables.php on line 91
Notice: Trying to get property ‘weatherStationName’ of non-object in /wp-content/plugins/ip2location-variables/ip2location-variables.php on line 92
Notice: Trying to get property ‘mcc’ of non-object in /wp-content/plugins/ip2location-variables/ip2location-variables.php on line 93
Notice: Trying to get property ‘mnc’ of non-object in /wp-content/plugins/ip2location-variables/ip2location-variables.php on line 94
Notice: Trying to get property ‘mobileCarrierName’ of non-object in /wp-content/plugins/ip2location-variables/ip2location-variables.php on line 95
Notice: Trying to get property ‘elevation’ of non-object in /wp-content/plugins/ip2location-variables/ip2location-variables.php on line 96
Notice: Trying to get property ‘usageType’ of non-object in /wp-content/plugins/ip2location-variables/ip2location-variables.php on line 97
]]>Hello,
sorry I do not get the instruction so far. Can someone give me a code example in php to display the IP address or lat/long of the visitor? I tried several things but its not working …
It would be very helpful if the plugin would offer shortcodes to display the ip2location data directly in pages, posts and so on.
Thank you!
]]>I notice if the website uses Cloudflare them, sometimes instead of real IP location appear location of Cloudflare Server, how to bypass this issue?
]]>After updating to latest version, it’s not show anything
With old version, it’s work:
<?php ip2location_get_vars(‘IP_ADDRESS’) ?>
So, how to display simple the IP adddress?
]]>Since installing the ip2location plugin on my local WP installation, I’m getting the following errors:
Notice: register_uninstall_hook was called incorrectly. Only a static class method or function can be used in an uninstall hook. Please see Debugging in WordPress for more information. (This message was added in version 3.1.) in C:\xampp\htdocs\WP\wp-includes\functions.php on line 3547
Notice: has_cap was called with an argument that is deprecated since version 2.0! Usage of user levels by plugins and themes is deprecated. Use roles and capabilities instead. in C:\xampp\htdocs\WP\wp-includes\functions.php on line 3495
Any help in fixing these?
]]>hi. I have installed, activate & downloaded DB5-Lite Database for this plugin successfully. Then i put this code in my themes’s functions.php:
$data = ip2location_get_vars();
$data = json_decode($data);
$ip2_cc = $data->countryCode;
var_dump($ip2_cc);
but $ip2_cc doesn’t get value & it returns NULL.
i also tried
$ip2_cc = $_SERVER['IP2LOCATION_COUNTRY_SHORT'];
var_dump($ip2_cc);
with same result (NULL).
am i doing wrong?
how should i use it in my theme’s functions.php ?
Hello. I have installed the plugin, and I have uploaded the database.bin file to the directory. I still get the error message that the bin file doesn’t exist. Also, can you give a simple example of how to use this? Let’s say I want to only show a message to somebody who is in the state of Minnesota. Thanks.
]]>