Signup from U.S. ip's only ... Is it possible?

TxFestus - July 9, 2007 - 00:22

Hello all, I have a question about signup limitations/restrictions.

I have been testing Drupal and WordPressMU for my new ".us" site. I'm almost sold on using Drupal at this point. The only question I have is about a plugin. There is a 'widget' for WPMU that restricts a signup based on the users IP country code. Is there such a thing available for Drupal?

In general, if a user comes to the site from an IP that has a U.S. country code then they can sign up. If their IP indicates they are from another country then they get an error message stating that signups are intended for U.S. users and that their IP indicates that they are from "country code ##". The error then instructs them to email admin with information to have account manually added in case of errors or whatever.

I'm setting up a ".US" site for "patriotic bloging" and just wondered if this is possible.

I have nothing against the other users in other countries, but wanted to make this a "U.S." blog portal if possible. At this time I just don't see a lot of users from other coutries wanting to come by and join a U.S. Patriotic blog site, but I may be wrong.

Any ideas, suggestions or comments are appreciated.

Thanks

ps, I'm a Drupal noob so be nice.

Have it converted

NancyDru - July 9, 2007 - 00:39

If you can get that widget, you can convert it, or have someone else convert it. It may not be terribly complicated.

Nancy W.
Drupal Cookbook (for New Drupallers)
Adding Hidden Design or How To notes in your database

Who is your target audience?

tm - July 9, 2007 - 01:22

You may wish to consider who you are filtering out/allowing in with a geographic filter. Not a Drupal thing, more matter of strategy for your site and/or organization.

It is your site, so do as you wish, but there are a "few" people not residing within U.S. borders that may wish to participate in such a "patriotic" site; military, global affiliates, people on long-term assignment, "friends," etc. Granted, if none of your target audience ever leaves the country, then this is a moot point.

Good luck!

Hi, thanks to both of you

TxFestus - July 9, 2007 - 03:05

Hi, thanks to both of you for replying.

As far as target audience .... open. I understand the need to allow people outside of the us to signup, but that could be done manually if need be using the stock error message the script maker uses.

The plugin (php code / more of a filter actually after I went back and downloaded it) is located here http://mu.wordpress.org/forums/topic.php?id=5508. The download consists of a php page with script and that's it. No real instructions on where to place it. I'm guessing somewhere at the top of the signup page.

If you are not accessing their site from New Zealand then you can go here and see the end results of a "non" country trying to sign up .... http://blogtown.co.nz/wp-signup.php

I'm also including the php code here for reference to make it easier for help.

<?php
/*
Plugin Name: Limit Country Signups
Plugin URI: <a href="http://stuart.amanzi.co.nz
Description:" title="http://stuart.amanzi.co.nz
Description:" rel="nofollow">http://stuart.amanzi.co.nz
Description:</a> Allows the site admin to limit signups to a specific country.
Version: 0.1
Author: Stuart Maxwell
Author URI: <a href="http://stuart.amanzi.co.nz
*/
/*" title="http://stuart.amanzi.co.nz
*/
/*" rel="nofollow">http://stuart.amanzi.co.nz
*/
/*</a>  Copyright 2006  Stuart Maxwell  (email : <a href="mailto:stuart@amanzi.co.nz" rel="nofollow">stuart@amanzi.co.nz</a>)

    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
*/


/**
* Country lookup code
*/
function amanzi_limit_country_signups() {
       
$ip = $_SERVER['REMOTE_ADDR'];
       
$url = 'http://api.hostip.info/country.php?ip='.$ip;
       
$lines_array = file($url);
       
$country $lines_array[0];
       
$err_msg = 'Sorry, only New Zealand residents can sign up for a blog at Blogtown NZ. You appear to be coming from the following country code: ' . $country;
        if(
$country != 'NZ') {
               
wp_die( $err_msg );
        }
}
add_filter('signup_header', 'amanzi_limit_country_signups');
?>

In searching I also found this site (http://webnet77.com/scripts/geo-ip/index.html) that has an IP to country database that can be used. Don't know if maybe the two together could make what I'm wanting.

In searching the above I found this in their forum about what their scripts would need to capture the IP of a visitor. Thought it might help someone who may be looking into this.
... http://bibleforums.org/forum/showthread.php?t=85177&highlight=country+sc... ...

Thanks for the help

Thanks Nancy

TxFestus - July 11, 2007 - 00:09

Thanks Nancy for even giving this a shot. I really appreciate the effort.

I'm also open to other ideas if anyone has any.

thanks again

Still working on it

NancyDru - July 12, 2007 - 00:44

I've had a few problems with the database not wanting to load, but I got past that.

Nancy W.
Drupal Cookbook (for New Drupallers)
Adding Hidden Design or How To notes in your database

More info for possible helpers ...

TxFestus - July 14, 2007 - 23:05

Here's some more ip to country information (along with a downloadable database file) that I found.
It might help give a new idea or approach to the wanted goal.

http://ip-to-country.webhosting.info/node/view/5

thanks to all who takes the time to work on this.

ip2cc module

sugree - July 17, 2007 - 04:39

You may use ip2cc module and below snippet to validate incoming user in registration form.

<?php
$allowed_cc
= array("us");

$addr = $_SERVER['REMOTE_ADDR'];
$country = module_invoke('ip2cc','get_country',$addr);
if (isset(
$country)) {
 
$cc = strtolower($country->country_code);
  if (!
in_array($cc,$avail_cc)) {
   
form_set_error('country',t('Your country are not allowed to register on this site.'));
  }
}
?>

For more information, please read How to display information based on geo location using ip2cc and How does IP to country module work

www.howforge.com

 
 

Drupal is a registered trademark of Dries Buytaert.