The MU forums have moved to

New plugin - limit signups to specific country (7 posts)

  1. amanzi
    Posted 17 years ago #

    Not everyone would want this, but I thought I would share anyway...

    I created a simple plugin which checks the IP address of visitors accessing the signup form. If they don't originate from a country of your choice, they receive an error message.

    I wanted this because I only wanted my site to be used by people in NZ to keep that 'niche' feel. And I was getting heaps of splogs from overseas.

    If you're not in NZ you can see the plugin here:

    (by the way... I know it's not fool-proof, but it works well enough.)

  2. lunabyte
    Posted 17 years ago #

    Hmmm... That's pretty spiffy for niche sites.

    Like you say, not fool proof, but every little bit helps.

  3. qrof
    Posted 17 years ago #

    Nice plugin! I've modified it though, changed the IP check to use GEOIP database which is more accurate imo, and also faster since it uses a local DB file.

    $gi = geoip_open("GeoIP.dat",GEOIP_STANDARD);
    $country = geoip_country_code_by_addr($gi, $ip);
    if($country) != 'SI') {
      wp_die( $err_msg );

    GEOIP database is available at

  4. Ovidiu
    Posted 17 years ago #

    I'll give this mod a try, as the original, didn't even know about my current residential country :-) it just gave XX back instead of my countrycode...

  5. qrof
    Posted 17 years ago #

    That's why I've switched to GeoIP, seems it's more accurate.

  6. poddys
    Posted 15 years ago #

    I am looking for something similar, only to identify the country of a visitor so that I can display specific code in the sidebar.

    I have a set of rotating ads on Commission Junction, using a Smartzone, that just includes links from the USA. I would like to add multiple Smartzones with ads from specific countries, and display the appropriate one, depending on where the visitor is from.

    I am not sure what code I would need to add in the sidebar though. I am looking for something like...

    If country = GB display GB ad code, else display USA ad code.

    Thanks for any help...

  7. tdjcbe
    Posted 15 years ago #

    In all honestly, I'd ask CJ about that. Last time I checked, they had something in their AUP about modifying their code. I don't see a problem since all you;re doing is choosing which of their codes you want to display but they even might have something in place already for use.

    I was going to suggest for a source but I can;t get the site to come up.

    But anyway, maybe something like this as a start would be helpful:

About this Topic