Title: Functions returning NULL
Last modified: January 24, 2020

---

# Functions returning NULL

 *  [Duke](https://wordpress.org/support/users/dukessa/)
 * (@dukessa)
 * [6 years, 4 months ago](https://wordpress.org/support/topic/functions-returning-null/)
 * Hello,
    I dont understand if Im missing something or there’s a problem with APIs.
   Using HostIP.info Web-API. I can’t see any useful info and your examples return
   NULL.
 * This
 *     ```
       $userInfo = geoip_detect2_get_info_from_current_ip();
       var_dump($userInfo);
       ```
   
 * Returns
 *     ```
       object(YellowTree\GeoipDetect\DataSources\City)#12111 (13) {
         ["extra":protected]=>
         object(YellowTree\GeoipDetect\DataSources\ExtraInformation)#12124 (2) {
           ["validAttributes":protected]=>
           array(6) {
             [0]=>
             string(6) "source"
             [1]=>
             string(6) "cached"
             [2]=>
             string(5) "error"
             [3]=>
             string(8) "original"
             [4]=>
             string(4) "flag"
             [5]=>
             string(3) "tel"
           }
           ["record":"GeoIp2\Record\AbstractRecord":private]=>
           array(3) {
             ["source"]=>
             string(8) "hostinfo"
             ["cached"]=>
             int(1579888209)
             ["error"]=>
             string(0) ""
           }
         }
         ["city":protected]=>
         object(GeoIp2\Record\City)#12122 (3) {
           ["validAttributes":protected]=>
           array(3) {
             [0]=>
             string(10) "confidence"
             [1]=>
             string(9) "geonameId"
             [2]=>
             string(5) "names"
           }
           ["locales":"GeoIp2\Record\AbstractPlaceRecord":private]=>
           array(2) {
             [0]=>
             string(2) "it"
             [1]=>
             string(2) "en"
           }
           ["record":"GeoIp2\Record\AbstractRecord":private]=>
           array(0) {
           }
         }
         ["location":protected]=>
         object(GeoIp2\Record\Location)#12119 (2) {
           ["validAttributes":protected]=>
           array(9) {
             [0]=>
             string(13) "averageIncome"
             [1]=>
             string(14) "accuracyRadius"
             [2]=>
             string(8) "latitude"
             [3]=>
             string(9) "longitude"
             [4]=>
             string(9) "metroCode"
             [5]=>
             string(17) "populationDensity"
             [6]=>
             string(10) "postalCode"
             [7]=>
             string(16) "postalConfidence"
             [8]=>
             string(8) "timeZone"
           }
           ["record":"GeoIp2\Record\AbstractRecord":private]=>
           array(1) {
             ["time_zone"]=>
             NULL
           }
         }
         ["postal":protected]=>
         object(GeoIp2\Record\Postal)#12123 (2) {
           ["validAttributes":protected]=>
           array(2) {
             [0]=>
             string(4) "code"
             [1]=>
             string(10) "confidence"
           }
           ["record":"GeoIp2\Record\AbstractRecord":private]=>
           array(0) {
           }
         }
         ["subdivisions":protected]=>
         array(0) {
         }
         ["continent":protected]=>
         object(GeoIp2\Record\Continent)#12112 (3) {
           ["validAttributes":protected]=>
           array(3) {
             [0]=>
             string(4) "code"
             [1]=>
             string(9) "geonameId"
             [2]=>
             string(5) "names"
           }
           ["locales":"GeoIp2\Record\AbstractPlaceRecord":private]=>
           array(2) {
             [0]=>
             string(2) "it"
             [1]=>
             string(2) "en"
           }
           ["record":"GeoIp2\Record\AbstractRecord":private]=>
           array(0) {
           }
         }
         ["country":protected]=>
         object(GeoIp2\Record\Country)#12113 (3) {
           ["validAttributes":protected]=>
           array(5) {
             [0]=>
             string(10) "confidence"
             [1]=>
             string(9) "geonameId"
             [2]=>
             string(17) "isInEuropeanUnion"
             [3]=>
             string(7) "isoCode"
             [4]=>
             string(5) "names"
           }
           ["locales":"GeoIp2\Record\AbstractPlaceRecord":private]=>
           array(2) {
             [0]=>
             string(2) "it"
             [1]=>
             string(2) "en"
           }
           ["record":"GeoIp2\Record\AbstractRecord":private]=>
           array(0) {
           }
         }
         ["locales":protected]=>
         array(2) {
           [0]=>
           string(2) "it"
           [1]=>
           string(2) "en"
         }
         ["maxmind":protected]=>
         object(GeoIp2\Record\MaxMind)#12117 (2) {
           ["validAttributes":protected]=>
           array(1) {
             [0]=>
             string(16) "queriesRemaining"
           }
           ["record":"GeoIp2\Record\AbstractRecord":private]=>
           array(0) {
           }
         }
         ["registeredCountry":protected]=>
         object(GeoIp2\Record\Country)#511 (3) {
           ["validAttributes":protected]=>
           array(5) {
             [0]=>
             string(10) "confidence"
             [1]=>
             string(9) "geonameId"
             [2]=>
             string(17) "isInEuropeanUnion"
             [3]=>
             string(7) "isoCode"
             [4]=>
             string(5) "names"
           }
           ["locales":"GeoIp2\Record\AbstractPlaceRecord":private]=>
           array(2) {
             [0]=>
             string(2) "it"
             [1]=>
             string(2) "en"
           }
           ["record":"GeoIp2\Record\AbstractRecord":private]=>
           array(0) {
           }
         }
         ["representedCountry":protected]=>
         object(GeoIp2\Record\RepresentedCountry)#12120 (3) {
           ["validAttributes":protected]=>
           array(6) {
             [0]=>
             string(10) "confidence"
             [1]=>
             string(9) "geonameId"
             [2]=>
             string(17) "isInEuropeanUnion"
             [3]=>
             string(7) "isoCode"
             [4]=>
             string(5) "names"
             [5]=>
             string(4) "type"
           }
           ["locales":"GeoIp2\Record\AbstractPlaceRecord":private]=>
           array(2) {
             [0]=>
             string(2) "it"
             [1]=>
             string(2) "en"
           }
           ["record":"GeoIp2\Record\AbstractRecord":private]=>
           array(0) {
           }
         }
         ["traits":protected]=>
         object(GeoIp2\Record\Traits)#12121 (2) {
           ["validAttributes":protected]=>
           array(16) {
             [0]=>
             string(22) "autonomousSystemNumber"
             [1]=>
             string(28) "autonomousSystemOrganization"
             [2]=>
             string(14) "connectionType"
             [3]=>
             string(6) "domain"
             [4]=>
             string(9) "ipAddress"
             [5]=>
             string(11) "isAnonymous"
             [6]=>
             string(16) "isAnonymousProxy"
             [7]=>
             string(14) "isAnonymousVpn"
             [8]=>
             string(17) "isHostingProvider"
             [9]=>
             string(17) "isLegitimateProxy"
             [10]=>
             string(3) "isp"
             [11]=>
             string(13) "isPublicProxy"
             [12]=>
             string(19) "isSatelliteProvider"
             [13]=>
             string(13) "isTorExitNode"
             [14]=>
             string(12) "organization"
             [15]=>
             string(8) "userType"
           }
           ["record":"GeoIp2\Record\AbstractRecord":private]=>
           array(1) {
             ["ip_address"]=>
             string(13) "87.16.xxx.xxx"
           }
         }
         ["raw":protected]=>
         array(4) {
           ["traits"]=>
           array(1) {
             ["ip_address"]=>
             string(13) "87.16.xxx.xxx"
           }
           ["is_empty"]=>
           bool(true)
           ["extra"]=>
           array(3) {
             ["source"]=>
             string(8) "hostinfo"
             ["cached"]=>
             int(1579888209)
             ["error"]=>
             string(0) ""
           }
           ["location"]=>
           array(1) {
             ["time_zone"]=>
             NULL
           }
         }
       }
       ```
   
 * How am I supposed to get the country name (in english is fine), from this??
 * Thank you!

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

 *  [Benjamin Pick](https://wordpress.org/support/users/benjamin4/)
 * (@benjamin4)
 * [6 years, 4 months ago](https://wordpress.org/support/topic/functions-returning-null/#post-12364156)
 * Did you try to enter other ips (such as 8.8.8.8) in the backend look-up form?
 *  Thread Starter [Duke](https://wordpress.org/support/users/dukessa/)
 * (@dukessa)
 * [6 years, 4 months ago](https://wordpress.org/support/topic/functions-returning-null/#post-12365638)
 * No, but I did try with the other function (where you can lookup an arbitrary 
   IP).
    However, after switching to Ipstack Web-API it worked fine… maybe the API
   for HostIP.info changed?
 *  [Benjamin Pick](https://wordpress.org/support/users/benjamin4/)
 * (@benjamin4)
 * [6 years, 4 months ago](https://wordpress.org/support/topic/functions-returning-null/#post-12366526)
 * Did you try your IP on the website [http://www.hostip.info/](http://www.hostip.info/)
   itself? When I enter “87.16.1.1” there he says
 * Location: … actually we haven’t a clue.
 * which can happen. “8.8.8.8” works with the plugin on my dev wordpress.

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

The topic ‘Functions returning NULL’ is closed to new replies.

 * ![](https://ps.w.org/geoip-detect/assets/icon-256x256.jpg?rev=978998)
 * [Geolocation IP Detection](https://wordpress.org/plugins/geoip-detect/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/geoip-detect/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/geoip-detect/)
 * [Active Topics](https://wordpress.org/support/plugin/geoip-detect/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/geoip-detect/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/geoip-detect/reviews/)

 * 3 replies
 * 2 participants
 * Last reply from: [Benjamin Pick](https://wordpress.org/support/users/benjamin4/)
 * Last activity: [6 years, 4 months ago](https://wordpress.org/support/topic/functions-returning-null/#post-12366526)
 * Status: not resolved