• Resolved heartwired

    (@heartwired)


    Hey there!
    Love what you’ve done with the plugin.
    Unfortunately, I’m having an issue with getting the isoCode of Subdivisions using a shortcode.

    In your example, you show how to get the isoCode of a country:
    PHP – $userInfo->country->isoCode
    Shortcode – [geoip_detect2 property=”country.isoCode”]

    I’m trying to get the isoCode of the subdivision, but the Subdivisions object structure differs from all the others in the MaxMind GeoIP2 code. This is how the object starts:

    [subdivisions:protected] => Array
        (
            [0] => GeoIp2\Record\Subdivision Object
                (
                    [validAttributes:protected] => Array
                        (
                            [0] => confidence
                            [1] => geonameId
                            [2] => isoCode
                            [3] => names
                        )

    The other objects, such as country and city do not have the [0] => GeoIp2\Record\Subdivision Object line. This is an issue, because I’m not sure how to access the isoCode for this in a shortcode.

    I’m able to use php to print out the isoCode using $userInfo->subdivisions[0]->isoCode;
    My guess for the shortcode would be something like [geoip_detect2 property=”subdivisions.0.isoCode”] but that doesn’t work.

    Do you know of a way to access this via a shortcode?

    Hopefully that makes sense, and there’s a simple way to create a shortcode from this!
    Thanks for your help!

Viewing 7 replies - 1 through 7 (of 7 total)
Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Using Subdivisions in Shortcode’ is closed to new replies.