Skip to content
Benjamin Pick edited this page Nov 2, 2018 · 19 revisions

Technically speaking, how could I verify if my visitor comes from Germany?

Put this code somewhere in your template files:

$userInfo = geoip_detect2_get_info_from_current_ip();
if ($userInfo->country->isoCode == 'de')
    echo 'Hallo! Schön dass Sie hier sind!';

To see which property names are supported, refer to the list of Record Properties or to the plugin's Lookup page.

How can I show text only if the visitor is coming from Germany?

There are no shortcodes for this. Instead, you should use CSS:

.geoip { display: none !important; }
.geoip-country-DE .geoip-show-DE { display: block !important; }
<div class="geoip geoip-show-DE">
Shipping to Germany is especially cheap!
</div>

You need to enable the option Add a country-specific CSS class to the <body>-Tag to make this work. See [API Usage Examples#css-use] for a more elaborate example.

How can I add the current country name as text in my page?

Add this plugin shortcode somewhere in the page or post content:

Wie ist das Wetter in [geoip_detect2 property="country.name" lang="de" default="ihrem Land"] ?

For more information, check the API Documentation and API Usage Examples.

Which data source should I choose?

Each source has its advantages and disadvantages:

Cost Precision Performance
HostIP.info Free Low Low (Web-API)
Maxmind GeoIP2 Lite City/Country database Free Medium High (File)
Maxmind GeoIP2 City/Country database relatively high High High (File)
Maxmind GeoIP2 Precision not so high (paid per lookup query, so good for low traffic/use) High Low (Web-API)
  • If you choose "automatic", this plugin will install "Maxmind GeoIP2 Lite City" and update it monthly. This is the easiest option. However, beware that the Lite database is not licensed GPL, but Creative Commons ShareAlike-Attribution (see FAQ below).
  • If you choose "manual", you can use any of the file-based Maxmind-Databases. It's recommended that you update the database regularly, for example by using the shell script provided by Maxmind.
  • Column Cost: Please refer to the vendor site to view current prices. The price depends on several factors: if you need city or country data, if pay per month, per year, or per query, etc.
  • Column Precision: To compare the commercial and the free data of Maxmind, see accuracy stats per country.
  • Column Performance: There are great differences how long a lookup can take. The Web-APIs take 0.5-1 second per Lookup (that's why they are cached for new each IP you request data from), the File-based APIs only about 0.01 second.

Can I change the time period how long the data is cached?

By default, lookups via Web-API are cached for 7 days. If you want to define a different time span, add this code somewhere in your theme or plugin:

if (!defined('GEOIP_DETECT_READER_CACHE_TIME'))
	define('GEOIP_DETECT_READER_CACHE_TIME', 14 * DAY_IN_SECONDS);

The Maxmind Lite databases are licensed Creative Commons ShareAlike-Attribution. When do I need to give attribution?

Maxmind is writing:

"In most cases, a Wordpress site or other site that auto-detects
a default location/currency/language is not providing the GeoLite data
to others so they do not need to attribute. In contrast, a site that
allows users to look-up their own or other IP addresses would not 
to attribute since the data is being provided to others. ...

Please take a look at the following FAQ:
https://wiki.creativecommons.org/FAQ#Do_I_always_have_to_attribute_the_creator_of_the_licensed_material.3F "

Link to the official Licence information: http://dev.maxmind.com/geoip/geoip2/geolite2/

Does this plugin work in a WordPress MultiSite-Network environment?

There seem to be no issues with WordPress multisite, but it is not officially supported.

What do you mean by "This plugin is charity-ware"?

I have decided against trying to make this plugin profitable. Also, the work project I have been developing this for is long finished. If you want to encourage me to keep on maintaining this, and say "thank you for your work", please consider donating for this charity:

Youth With A Mission, Hainichen, Germany is a Christian non-profit organisation whose main aim is to strengthen the value of family in society.

Paypal Donate

You can’t perform that action at this time.