WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

So I have got one hater in India who bombarded on my adsense ad units. Luckily I didn't get banned from Google. I have blocked Indian visitors from my site using iq-blockcountry plugin (wordpress). Now I want to know if there's any procedure so that I can allow the Indian visitors but hide the adsense units from them? I don't want to block all visitors just because of one foolish person.

share|improve this question

closed as off topic by anu, Brian Fegter, Chris_O, Wyck, kaiser Sep 3 '12 at 22:33

Questions on WordPress Development Stack Exchange are expected to relate to WordPress within the scope defined by the community. Consider editing the question or leaving comments for improvement if you believe the question can be reworded to fit within the scope. Read more about reopening questions here.If this question can be reworded to fit the rules in the help center, please edit the question.

up vote 1 down vote accepted

A quick google search gave me this. This plugin seems to have this feature: http://wordpress.org/extend/plugins/ad-injection/faq/

How can I show different ads to people in different countries?

If you install the Country Filter plugin (with the IP database) then you can use the following code in the direct ad insertion modes. This will not work in mfunc mode!

<?php if (function_exists('isCountryInFilter')) { ?>
<?php if(isCountryInFilter(array("uk"))) { ?>

UK advert

<?php } else { ?>

Global advert

<?php } } ?>

-- since above is a paying option. what you can do is .

use remote_addr to get your visitors ip


next use a networkservice that can provide you this information, or you can make functions for that yourself using available databases.

--- your easiest solution would be to use geolocation, but then your users have to agree with this.

share|improve this answer
Country Filter WordPress plugin is not available for free :/ – Chankey Pathak Aug 21 '12 at 10:39
So it seems, you could program this quite easily. If you get the users country just a simple if else would do. No idea what your dev skills are? – woony Aug 21 '12 at 11:41
From where can I get the IP addresses of a country? (for free obviously) – Chankey Pathak Aug 22 '12 at 5:27
It's not our job to google for you. Or look around here. I'll guide you . Look for remote_addr > this is how you can get your visitors ip. then look for services on how to retrieve the country from that. I'll add some to my answer above. – woony Aug 22 '12 at 7:03
Got it, thanks :) – Chankey Pathak Aug 22 '12 at 7:45

Not the answer you're looking for? Browse other questions tagged or ask your own question.