iQ Block Country (a WordPress plugin)
iQ Block Country is a wordpress plugin that allows you to block visitors based on from which country they are from.
This plugin is tested with WordPress 2.9.2, this is also the version which was first used to test it so no guarantees it will work on prior versions. This plugin also works for WordPress 3.0.1
Latest version: 1.0.4
Description
If you want to block people from certain (obscure) countries that have no business visiting your blog and perhaps only leave spam comments or other harmful actions than this is the plugin for you.
Choose which countries you want to ban from visiting your blog. Any visitors from that country get a HTTP/403 error with the message “Forbidden – Users from your country are not permitted to browse this site.”
They will not be able to do harmful things to your blog like post comment spam.
This plugin uses the GeoLite database from Maxmind. It has a 99.5% accuracy so that is pretty good.
Once you setup this plugin it will try to download the GeoIP database from Maxmind so you will always have a recent version of the database when installing this plugin.
Installation
1. Unzip the archive and put the `iq-block-country` folder into your plugins folder (/wp-content/plugins/).
2. Activate the plugin through the ‘Plugins’ menu in WordPress
3. Go to the settings page and choose which countries you want to ban. Use the ctrl key to select
multiple countries
4. Check if it downloaded the GeoIP database from MaxMind otherwise follow instructions on screen.
Frequently Asked Questions
Q: Does this plugin also work with IPv6?
A: No not yet. Maxmind has a GeoIPv6 database though just no support for PHP yet.
And as my blog is also reachable on IPv6 I might incoporate this database as soon this is possible.
However: We need more IPv6 out there so please DO ask your hosting provider for IPv6!
Q: How can I get a new version of the GeoIP database?
A: You can remove the file GeoIP.dat from the plugin directory and after removal go to the settings page of this plugin. When it sees the GeoIP database is missing it will try to download it for you.
However you can also download the GeoIP database yourself from Maxmind and overwrite the existing database.
Since version 1.0.4 you can also press the “Download new GeoIP database” button in the admin menu.
Maxmind updates the GeoLite database every month.
Q: Help it gives some error about not being able to download the GeoIP database?
A: Follow the instructions on screen. It will probably tell you that you have to manually download the GeoIP database from Maxmind from the following url:
http://geolite.maxmind.com/download/geoip/database/GeoLiteCountry/GeoIP.dat.gz
It will also give you the location it expects the GeoIP.dat file. So go ahead and download it and unzip the file to this specific location.
Q: How come that I still see visitors from countries that I blocked in Statpress or other statistics software?
A: It’s true that you might see hits from countries that you have blocked in your statistics software. That is the way it works, certain plugins may be run before iQ Block Country is run so it may log visitors to pages. This however does not mean this plugin does not work, it just means somebody tried to access a certain page or pages and that that fact is logged.
If you are worried this plugin does not work you could try to block your own country and afterwards visit your frontend website and see if it actually works. Also if you have access to the logfiles of the webserver that hosts your website you can see that these visitors are actually denied with a HTTP error 403.
Changelog
v1.0.4
- Added a button to download the new GeoIP database.
v1.0.3
- Updated the FAQ
- Try to make sure this plugin is loaded first to avoid “headers already sent” trouble.
v1.0.2
- PHP 5.2 or higher required
- Fixed an include bug when other plugins also use the MaxMind database. Thanks to Marcus from LunaWorX for finding this bug.
v1.0.1
- Included the necessary geoip.inc file
v1.0
- Initial release
Upgrade Notice
v1.0.3
This baby should just upgrade fine. You may want to deactivate and reactivate this plugin to make (pretty) sure this
plugin is loaded first. This especially recommended if you have problems with ‘headers already sent’ notices.
v1.0.2
PHP 5.2 or higher is now required.
Just upgrade if you have PHP 5.2 or higher.
v1.0.1
You can just upgrade. Actually we urge you to as else this plugin won’t work.
v1.0
Initial release
Download
You can download this plugin from the WordPress Plugin site: http://wordpress.org/extend/plugins/iq-block-country/
Planned features
- IPv6 support
- Blacklist ip addresses as sometimes you just don’t want to ban an entire country
- Whitelist ip addresses, maybe you want to ban a whole country except some good guys
Feature requests
If you miss a certain feature or if you would like to see something else changed or added please let me know. I am open to any suggestion that may improve this plugin.
Gerelateerde artikelen:
U kunt reacties op dit bericht volgen via de RSS 2.0 feed. U kunt een bericht achterlaten, of een trackback geven op uw eigen site.


how can i change the block message from “Forbidden – users from your country are not allowed to view this site” to something else. I tried to edit the .php file in WP plugins editor but it wont save, keeps reverting back to the original message.
The only way at this moment is to edit the PHP code. Perhaps if it doesn’t work through the editor you can FTP the file to your desktop and edit it by notepad (or vi ofcourse
)
Hello, thanks for your hard work. When using IQBlock Country how do we see the growing list of blocked countries? We select and save, but a list of blocked countries does not appear on the screen or in the code?
Please advise?
Thank you.
Hi,
The way you van view which countries are selected is by scrolling down the selection list after submit. All selected countries should remain selected.
Which countries are actually selected is written to the wordpress database so you can also see it also in the database if you are a more advanced user (by country code).
Are you able to block a country but allow certain ip addresses access?
Hi,
Unfortunatly not. This is still on my wish list. I’ve already put some code in place for this but it is not yet finished.
Ok, thank you anyway. By the way this plugin is great. Works perfectly!
I still see in my login logs that people from countries I have blocked are able to visit the login page and attempt to login. How?
Perhaps you made an error in selecting that specific country? You can check on the Maxmind website which country it thinks it belongs to a specific IP address. This may be different from the domainname.tld
I used default and selected EVERY country except Canada and USA. Yet I am getting login attempts from Russia and other countries.
Just checked the IP on maxmind and it shows the IP is from russia as well. I have redownloaded the database yesterday and still got hits from the IP today. Is this plugin compatible with 3.3.1?
Aah never mind. I understood your question wrong I think. The plugin only works on the frontend. Aka the pages that get displayed to the public.
It does not work for the backend (otherwise you might lock yourself out).
If you want to block access to your wp-admin url there is an easy solution with .htaccess but there are probably also other plugins that protect the backend.
hi yes, i would love to have the feature to BLOCK MY OWN COUNTRY and yet allow myself access to edit and view my own wordpress site from within my own country. hope that feature gets implemented soon. thanks for this plugin.
I hope to get around doing some work on this plugin sooner than later
Just curious why you want to block your own country.
Thank for great plugin
but can you tell me how to change the Title of blog message page ?
because on blocked page it still show my blog name
i want to change it with any other title
ex : title: 404 not found
thank so much.
You can’t. WordPress starts displaying the page (and it starts with the header where the title of the current page is in) then it fires up the plugin which checks if a country is blocked or not.
So in the current setup the headers are always displayed.
Greetings;
First, I’d like to say this is a great plugin! You have done a great service to those of us adminin’ blogs – Thank you!
However, there is two small (very small) problems with the coding.
1) When using the plugin editor the only files editable are the files in the “Trunk” folder. As per above, to edit the actual working files you have to do it with a different text editor outside the confines of WordPress.
Not really that big a deal for those of us that have done this before but may be irritating for some newbies – ;o)
2) Please consider using a uniform “<?php" php opener accross the whole code block. Some web servers are using the explicet "<?php" to run code. Using the "<?" opener breaks the code when trying to display the list of countries on the configuration page.
This is an easy fix by changing the "<?" to "<?php" in the code.
Thanks again for your dedication to the wordpress environment. Your contribution is a great one indeed!
Take Care,
Phil
Hi Phil,
Thanks for the comments.
I had some trouble with SVN the last time around so that may be root cause to this trunk error
I viewed the code and I see that I use "<?" once indeed. I will fix this in the next release as it may indeed lead to problems.