As a supplement of WordPress IP to Country Plugin created by Priyadi Iman Nurcahyo, I created a very simple WordPress plugin named IPCT Plugin. This plugin detects the city name of the visitors based on their IP number. I use the GeoLiteCity database to translate IP number into the city name.
Requirement
- WordPress 2.0 or newer
- Basic knowledge of PHP
Installation
- Download the latest GeoLiteCity binary format.
- Unzip the file to get GeoLiteCity.dat
- Download GeoIP PHP API Module. You need to download geoip.inc, geoipcity.inc, and geoipregionvars.php.
- Rename geoip.inc into geoip.inc.php.
- Rename geoipcity.inc into geoipcity.inc.php.
- Open geoipcity.inc.php and change the line “require_once ‘geoip.inc’;” into “require_once ‘geoip.inc.php’;”
- Download ipct.txt and rename it into ipct.php.
- Create new directory named ipct inside your wp-content/plugins directory.
- Upload geoip.inc.php, geoipcity.inc.php, geoipregionvars.php, ipct.php, and GeoLiteCity.dat into your wp-content/plugins/ipct directory.
- Activate the plugin from your WordPress plugin menu.
Usage
- Open your theme comments.php file with a text editor.
- Use the function yahya_print_city($comment->comment_author_IP) inside the comment loop.
That’s all.
If you want to see the result, just put a comment here 🙂
Follow me on social media:
Leave a Reply