-
-
Notifications
You must be signed in to change notification settings - Fork 38
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.
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.
Or, 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.
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.
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/
Maybe. I haven't tested it.
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. I did my civil service there and still try to support them when I can.
If you are living in Germany and like to have a tax-deductible receipt, please do it by bank account and give them your address.
Content of this documentation is available under Creative Commons Attribution-Share Alike 3.0 Unported License. Feel free to improve it by logging in with a Github user and editing it.