GeoIP Detection

Wordpress Plugin
Download latest - 5.1.1

Developers

benjaminpick
benjamin4

Download Stats

Today 29
Yesterday 58
Last Week 671
All Time 107,818
Banner 772x250

Provides geographic information detected by an IP adress. This can be used in themes or other plugins, as a shortcode, or via CSS body classes. The city & country names are translated in different languages (supported languages).

Features:

  • You can use one of these data sources (see comparison):
    • Free (default source): HostIP.info (IPv4 only)
    • Free with registration: Maxmind GeoIP2 Lite City, automatically updated weekly
    • Commercial: Maxmind GeoIP2 City or Maxmind GeoIP2 Country
    • Commercial Web-API: Maxmind GeoIP2 Precision (City, Country or Insights)
    • Hosting-Provider dependent: Cloudflare or Amazon AWS CloudFront (Country)
    • Free or Commercial Web-API: Ipstack
    • Commercial Web-API via AWS Marketplace: Fastah
  • Provides these 5 functions (see API Documentation):
    • geoip_detect2_get_info_from_ip($ip, $locales <h4>array('en'), $options</h4> array()): Lookup Geo-Information of the specified IP
    • geoip_detect2_get_info_from_current_ip($locales <h4>array('en'), $options</h4> array()): Lookup Geo-Information of the current website user
    • geoip_detect2_get_current_source_description(...): Return a human-readable label of the currently chosen source.
    • geoip_detect2_get_external_ip_adress(): Fetch the internet adress of the webserver
    • geoip_detect2_get_client_ip(): Get client IP (even if it is behind a reverse proxy)
  • For the property names, see the results of a specific IP in the wordpress backend (under Tools > Geolocation IP Detection).
  • You can include these properties into your posts and pages by using the shortcode [geoip_detect2 property="country.name" default="(country could not be detected)" lang="en"] (where 'country.name' can be one of the other property names as well, and 'default' and 'lang' are optional).
  • You can show or hide content by using a shortcode [geoip_detect2_show_if country="FR, DE" not_city="Berlin"]TEXT[/geoip_detect2_show_if]. See Shortcode Documentation.
  • When enabled on the options page, it adds CSS classes to the body tag such as geoip-province-HE, geoip-country-DE and geoip-continent-EU.
  • If you are using a page cache, it is recommended to use the AJAX mode (see AJAX)
  • When enabled on the options page, the client IP respects a reverse proxy of the server.
  • If you are using Contact Form 7, you can use these shortcodes:
    • A select input with all countries, the detected country being selected by default: [geoip_detect2_countries mycountry]
    • A text input that is pre-filled with the detected city (or other property): [geoip_detect2_text_input city property:city lang:fr id:id class:class default:Paris]
    • Geolocation information for the email text: [geoip_detect2_user_info]
  • Together with SVG Flags you can show the flag of the detected country: [geoip_detect2_current_flag] (see documentation)

See Documentation for more info.

How can I use these functions?

  • You could choose the currency of the store based on the country name
  • You could pre-fill the shipping country
  • You could show the store nearest to your customer
  • You show or hide content specific to a geographic target group
  • Etc. ... You tell me! I'm rather curious what you'll do with this plugin!
  • Be careful to comply to the applicable laws. For example Regulation (EU) 2018/302 ...
  • If you need to get the user's timezone, it is more accurate to use JS solutions.

System Requirements: You will need at least PHP 7.2.5 If you use the plugin WooCommerce, you'll need at least WooCommerce 3.9.0 .

GDPR: See Is this plugin GDPR-compliant?

This extension is "charity-ware". If you are happy with it, please leave a tip for the benefit of this charity. (See FAQ for more infos.)

Here are other ways to contribute to the development of this plugin.

This product can provide GeoLite2 data created by MaxMind, available from http://www.maxmind.com.


Releases (40 )

Version Release Date Change Log
5.1.1 2022-10-27
  • NEW: For the reverse proxy configuration, internal adresses (such as 10.0.0.0/8) are now whitelisted by default. You can override this behaviour by using the wordpress filter geoip_detect2_client_ip_whitelist_internal_ips.
  • NEW: Body classes now include the city name in English (e.g. geoip-city-Munich)
  • FIX: Some server configurations showed this warning: Use of undefined constant CURL_HTTP_VERSION_2_0
5.1.0 2022-10-27

New Datasource: Fastah Web API (beta), see https://aws.amazon.com/marketplace/pp/prodview-k5gjowexrefl2

AJAX mode: * NEW: The JS function geoip_detect.set_override_with_merge can modify the override record in one property, merging it with the currently saved property

Other minor changes: * FIX: In non-AJAX mode, properties such as "extra.original.zip" can be accessed again * FIX: Automatic download of Maxmind database now also works when the temp folder is group/world writeable (as in AWS configurations) * If you want to enable more Warnings (e.g. while debugging), you can add define('GEOIP_DETECT_DEBUG', true) to your wp-config.php or so. * Library updates

5.0.0 2022-01-07

If you are using AJAX mode, please read the changelog.

4.2.3 2021-07-26
  • FIX: Further improve the Maxmind admin notice UI
  • Update some smaller libraries
4.2.2 2021-07-19
  • FIX: Show Maxmind admin notice only on GeoIP pages to make it less intrusive
4.2.1 2021-07-19
  • FIX: Do not disable lookup automatically when potentially incompatible Maxmind libraries are found.
4.2.0 2021-07-16
  • NEW: Show a warning on the options page when there are incompatibilities with other plugins that also use the Maxmind libraries.
  • FIX: Remove an incompatibility of the libraries with Toolset or other Laravel-based plugins
  • NEW: In CF7, you can now add any property to the mail body with a special syntax, e.g. [geoip_detect2_property_country__iso_code]
  • FIX (JS): Replace the internally used library 'lodash' with 'just' to reduce the total file size
  • FIX (JS): Improve error handling in AJAX mode
  • FIX: Port numbers in reverse proxies are ignored now (removes incompatibility with Azure reverse proxies)
  • FIX: Prevent Cloudflare APO from caching when using AJAX mode or page caching is disabled in the plugin options
4.1.0 2021-03-11
  • NEW: An else shortcode for geoip_detect2_show_if and geoip_detect2_hide_if: [geoip_detect2_show_if city="Berlin"]Hallo Berlin![else]Not in Berlin[/geoip_detect2_show_if]
  • FIX: The JS for AJAX wasn't working for Safari browsers
  • FIX: Improving some edge cases of Record.get_with_locales() and other methods of Record to be consistent with non-AJAX mode
  • FIX: Revert more Maxmind libraries to fix incompatibility with WooCommerce
4.0.1 2021-03-02

Hotfix - avoid fatal erros if another plugin also has the Maxmind library included

4.0.0 2021-03-02

Improving Shortcodes (and Shortcodes for AJAX!) New Minimum Requirements: PHP 7.2.5, and if you use WooCommerce it needs to be 3.9.0 or later.

3.3.0 2020-12-15

Improving AJAX mode - now you can use it for specific pages.

3.2.1 2020-12-02

This update fixes an issue of 3.2.0 if your installation has WP_DEBUG enabled.

3.2.0 2020-11-26

This plugin version simplifies complying the the EULA of Maxmind by automatically retrieving and honoring their Privacy Exclusion List. You need to enter your Account ID in the options. Find more information about the Privacy Exclusion API in the FAQ of the plugin.

3.1.2 2020-11-04
  • NEW: The shortcode [geoip_detect2_text_input] now has a parameter type for hidden or other HTML5 input types (see Postal code example)
  • NEW: In all datasources, the new record property $record->extra->currencyCode for the currency code of the detected country has been added
  • FIX: Compatibility with PHP 8.0
3.1.1 2020-08-10
  • NEW: Add the possibility to access the ISO-3166 alpha3 version of $record->country: $record->extra->isoCode3 or [geoip_detect2 property="extra.countryIsoCode3"]
  • FIX: The (CF7) shortcode [geoip_detect2_countries] now selects the selected country on page reload (the HTML tag autocomplete is set to off now)
  • FIX: Subnets can now be entered in the preferences of the reverse proxy again (this was a regression of the Admin UI changes in 3.0.3)
  • FIX: Do not log "It has not changed since the last update." as a cron-related error that should be shown to the user.
3.1.0 2020-06-26

The property access for shortcodes has been rewritten so that property names such as "extra.original.zip" (Datasource: ipstack) are possible now.

3.0.4 2020-05-05
  • When an error occurs during the Cron update of the Maxmind database, it is now shown in the backend.
  • FIX: All times shown in the Admin backend now use the timezone set by Wordpress
  • FIX: In the Admin Options, it was not possible to revert an hardcoded "External IP of this server" back to "automatic detection"
  • FIX: [geoip_detect2_show_if property="country.isInEuropeanUnion" property_value="true"]Products list for EU[/geoip_detect2_show_if] now works properly (boolean values can be "true"/"yes" or "false"/"no")
  • FIX: [geoip_detect2_current_flag] now compatible with the SVG Flags version 0.9.0. See Documentation for more infos.
  • Minor admin improvement: If the value "IPs of trusted proxies" is set, but "The server is behind a reverse proxy" is not ticked, issue an warning
3.0.3.1 2020-03-31

Hotfix for the Manual download Maxmind datasource. The Plugin was renamed to Geolocation IP Detection in order to prevent trademark issues.

3.0.3 2020-03-27

The Plugin was renamed to Geolocation IP Detection in order to prevent trademark issues.

3.0.2 2020-03-26

The Plugin was renamed to Geolocation IP Detection in order to prevent trademark issues.

3.0.1 2020-01-08

3.0 was not compatible with the WooCommerce plugin.

3.0 2019-12-30

If you use Maxmind "Automatic download" then you need to upgrade to this plugin version in order to continue to receive database update. The Database licence changed and you will need to register at their website and agree to the EULA.

2.13.0 2019-12-02

PHP 5.6 is required now. If you are using the AJAX mode, this version will drastically reduce the number of requests as it will store the visitor's geo-information in a cookie.

2.12.1 2019-11-01
  • NEW: With the new Wordpress filter geoip_detect2_record_data_after_cache you can change the record data for testing purposes (see https://github.com/yellowtree/geoip-detect/wiki/API-Usage-Examples#change-record-data-eg-for-testing-purposes)
  • NEW: All datasources now also have the properties extra->flag (containing the flag as Unicode Emoji) and extra->tel (containing the country dial code)
  • Some cleanup in ipstack & showing all properties in backend.
2.12.0 2019-09-11

New: Ipstack.com can be used as data source

2.11.1 2019-07-13
  • FIX: When activating the plugin on Wordpress MultiSite, an error was thrown before
  • NEW: Add body class "geoip-country-is-in-european-union" if the detected country is inside of the European Union
  • JS/AJAX support for cached pages (Public BETA now. See https://github.com/yellowtree/geoip-detect/wiki/API%3A-AJAX)
  • NEW: If AJAX and body classes are enabled, body classes are added via AJAX.
2.11.0 2019-04-11

The Download code of the automatically updated Maxmind file was rewritten for better performance. Also, AJAX support is now in beta (see documentation).

2.10.0 2019-02-22
  • NEW: The whitelisted proxies can now be subnets such as 11.11.11.0/24
  • NEW: Add a ContactForm7-Tag geoip_detect2_text_input (see https://github.com/yellowtree/geoip-detect/wiki/API-Documentation#create-a-text-input-that-is-prefilled-with-a-geodetected-property)
  • NEW: A new wordpress filter allows overriding of the detected geo-information inside the geoip_detect2_shortcode_show_if-Shortcode. Use the already-existing filter geoip_detect2_record_information instead if you want to override this information for all shortcodes and API calls.
  • Updated Maxmind vendor code
  • Increased WP minimum version to 4.0
2.9.2 2018-12-04

Hotfix: In 2.9.1, this plugin was incompatible with other Contact Form 7-Special Mailtags (https://contactform7.com/special-mail-tags/).

2.9.1 2018-11-21

Online Shops: Be careful to comply to (EU) 2018/302 (going into effect 03 Dec 2018) in how you use this plugin !

2.9.0 2018-07-24

There have been changes to the reverse proxy logic. If you have enabled a reverse proxy, check if the detected IP is correct. New: Shortcode for showing/hiding content!

=

2.8.2 2018-01-13

This plugin version is compatible with PHP 7.2 and adapted the automatic update code.

2.8.0 2017-10-12

Warning: This bugfix version of the plugin requires PHP 5.4.

2.7.0 2017-03-17
  • ADD: The options array of geoip_detect2_get_info_from_ip now has a new parameter for overriding the current source for a single lookup. See API usage examples
  • ADD: New filter geoip_detect2_shortcode_country_select_countries for the country list of [geoip_detect2_countries]
  • ADD: New constant GEOIP_DETECT_IP_EMPTY_CACHE_TIME that can be used to specify a shorter cache time in case temporarily no external IP was found.
  • FIX: Compatibility with CF 4.6 (remove deprecated function call)
  • Maxmind vendor code was updated to the current version (2.4.5).
2.6.0 2016-09-30

Support for Cloudflare & AWS. 2 shortcodes for Contact Form 7.

2.5.7 2016-03-29
  • ADD: Shortcodes can now optionally specifiy the IP: [geoip_detect2 property="country.isoCode" ip="(ipv4 or ipv6)"]
  • ADD: Plugin is now translated into German.
  • FIX: geoip_detect2_get_info_from_current_ip() now also handles the case when REMOTE_ADDR contains multiple IP adresses
2.5.6 2016-02-05

Some users reported problems with open_basedir-notices - if that's you, this update will help. Otherwise there are no changes.

2.5.4 2015-12-03
  • FIX: Manual datasource filepath handling corrected.
  • FIX: Potential incompability with BuddyPress removed.
2.5.3 2015-10-15

This is a security update (please update).

1.8 2014-12-02
  • NEW: Support reverse proxies (you have to enable it in the plugin options.)
  • NEW: Shortcode now has a default value when no information for this IP found.