PDA

View Full Version : Limiting registration to users of one email domain.


MegaHertz
04-07-2004, 09:38 PM
I am getting ready to setup a forum and want to know if it is possible to allow users to register only if their email address is from a certain domain.

In other words I would like to exclude all domains, but the ones I specify. This would be the exact opposite of the way it is now.

I am just unsure of how to accomplish it. Any help or guidance would be greatly appreciated.

Hurricane
04-09-2004, 04:01 PM
I am looking into this for you.

MegaHertz
04-09-2004, 08:03 PM
Thanks Hurricane. :) I appreciate your help.

Hurricane
04-10-2004, 05:04 AM
I looked into doing this as a full blown hack, however, I do not think it will be worth going through the trouble. I do not think many people have the need for this. So I will come up with something for you that is quick and dirty. ;)

Hurricane
04-10-2004, 05:23 AM
I am getting ready to setup a forum and want to know if it is possible to allow users to register only if their email address is from a certain domain.

In other words I would like to exclude all domains, but the ones I specify. This would be the exact opposite of the way it is now.

I am just unsure of how to accomplish it. Any help or guidance would be greatly appreciated.


OK, here it is quick and dirty:

In your Admin Panel Options there is an area for email banning. (Which is the opposite of what you want as stated above.) What I have done is to allow you to reverse that function to only allow those who are listed.

Here you go:


Open includes/functions_user.php

Find This (Around Line 436)

// ###################### Start checkbannedemail #######################
function is_banned_email($email)
{
global $vboptions, $datastore;

if ($vboptions['enablebanning'] AND !empty($datastore['banemail']))
{
$bannedemails = preg_split('/\s+/', $datastore['banemail'], -1, PREG_SPLIT_NO_EMPTY);

foreach ($bannedemails AS $bannedemail)
{
if (is_valid_email($bannedemail))
{
$regex = '^' . preg_quote($bannedemail, '#') . '$';
}
else
{
$regex = preg_quote($bannedemail, '#');
}

if (preg_match("#$regex#i", $email))
{
return 1;
}
}
}

return 0;
}



REPLACE WITH:


// ###################### Start checkbannedemail #######################
function is_banned_email($email)
{
global $vboptions, $datastore;

if ($vboptions['enablebanning'] AND !empty($datastore['banemail']))
{
$bannedemails = preg_split('/\s+/', $datastore['banemail'], -1, PREG_SPLIT_NO_EMPTY);

foreach ($bannedemails AS $bannedemail)
{
if (is_valid_email($bannedemail))
{
$regex = '^' . preg_quote($bannedemail, '#') . '$';
}
else
{
$regex = preg_quote($bannedemail, '#');
}

if (preg_match("#$regex#i", $email))
{
return 0;
}
}
}

return 1;
}




What this has done is to switch the "return 0" and "return 1"


If you have any trouble with the above code let me know.

BTW: I did fully test this and it worked on my test BB.

MegaHertz
04-11-2004, 03:57 PM
Wow! Thanks-A-Million Hurricane I will test this out ASAP and let you know how it goes. :)

MegaHertz
04-18-2004, 03:58 PM
Just wanted to get back to you and let you know that this seems to be working perfectly. Thanks again for helping me out. :)