Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Contributor Taylor McCaslin

    (@taylor4484)

    Hi m1k3k, while GeoIP does not directly integrate into other plugins, it does expose it’s data in environment variables that you can call directly in custom PHP which you can use in any way you like:

    'countrycode'  => getenv( 'HTTP_GEOIP_COUNTRY_CODE' ),
    'countrycode3' => getenv( 'HTTP_GEOIP_COUNTRY_CODE3' ),
    'countryname'  => getenv( 'HTTP_GEOIP_COUNTRY_NAME' ),
    'latitude'     => getenv( 'HTTP_GEOIP_LATITUDE' ),
    'longitude'    => getenv( 'HTTP_GEOIP_LONGITUDE' ),
    'areacode'     => getenv( 'HTTP_GEOIP_AREA_CODE' ),
    'region'       => getenv( 'HTTP_GEOIP_REGION' ),
    'city'         => getenv( 'HTTP_GEOIP_CITY' ),
    'postalcode'   => getenv( 'HTTP_GEOIP_POSTAL_CODE' ),

    These same environment variables are exposed via easy to use shortcodes, which you can call directly in posts or with do_shortcode in custom php (https://codex.www.ads-software.com/Function_Reference/do_shortcode)

    1) Continent: [geoip-continent]
    2) Country: [geoip-country]
    3) Region (State): [geoip-region]
    4) City: [geoip-city]
    5) Postal Code: [geoip-postalcode]
    6) Latitude: [geoip-latitude]
    7) Longitutde: [geoip-longitude]
    8) Location: [geoip-location]

    With access to the GeoIP data, you should be able to write custom code to integrate into Geo My WP or any other plugin.

    Thread Starter m1k3k

    (@m1k3k)

    Thanks, Taylor, but as a person who is not familiar with coding, are there any places I can check out to sort of figure it out?

    Essentially I’m looking to pass the lat/long/zip data from GeoIP to the variables that Geo my WP uses to take advantage of caching.

    Again, I’m not a programmer but am more than willing to try. I

    Plugin Contributor Taylor McCaslin

    (@taylor4484)

    Support for custom code for third party plugin integrations is out of the scope of this support forum, but I’m happy to point you in the right direction.

    It looks like ‘Geo My WP’ does support hooks to provide default values. You should be able to hook into that extensibility to populate ‘Geo My WP’ with values from GeoIP using the data calls that I mentioned above.

    You can read details about the default form values in ‘Geo My WP’ here:
    https://docs.geomywp.com/gmw_default_form_values/

    I’d recommend contacting ‘Geo My WP’ support for details on how to leverage the hooks in that plugin to populate it with data from GeoIP.
    https://geomywp.com/support/

    I hope this helps!

    Thread Starter m1k3k

    (@m1k3k)

    Taylor, I was messing around and I think that the following code may work for others interested.

    function gmw_default_user_address( $gmw ) {
    
    	$address = getenv( 'HTTP_GEOIP_CITY' ).' ' .getenv( 'HTTP_GEOIP_REGION' ).' '.getenv( 'HTTP_GEOIP_POSTAL_CODE' ).' '.getenv( 'HTTP_GEOIP_COUNTRY_NAME' );
    	$gmw['ul_address'] = $address;
    
    	return $gmw;
    }
    add_filter( 'gmw_gmpt_default_form_values' , 'gmw_default_user_address' );
    Plugin Contributor Taylor McCaslin

    (@taylor4484)

    Glad to hear you got something working!

    Thanks for posting your code back here for others to leverage! Let us know if there is anything else we can help with.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Populate other fields with GeoIP data’ is closed to new replies.