MyBB Community Forums

Full Version: Restricting registration to email addresses from a specific domain
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I had this solved in 1.2, but now need to find a new solution.

I would like to restrict registration to my board to email addresses that end in aps1.net.

How can I do that in 1.4.3?
Bump. Any suggestions would be really appreciated! Thanks so much for your consideration.
(2008-11-12, 01:25 PM)teacherdavid Wrote: [ -> ]Bump. Any suggestions would be really appreciated! Thanks so much for your consideration.

Sorry... I didn't quite see this thread Undecided

It's quite easy - go to "Configuration" tab in the ACP, and then from the left menu select "Banning". There is a tab on this page that says "Disallowed Email Addresses". Add...

*@aps1.net

... and that should block them out...

Smile
I think they meant they only want that ending.

(2008-11-11, 05:37 AM)teacherdavid Wrote: [ -> ]I would like to restrict registration to my board to email addresses that end in aps1.net.
(2008-11-12, 04:45 PM)Matt_ Wrote: [ -> ]I think they meant they only want that ending.

Damn this posting and eating at-the-same-time business... I shouldn't do it! Rolleyes

In that case, you'll need to reverse the coding for the email restriction function...
In member.php, find:
$plugins->run_hooks("member_do_register_start");
After that line, add:
if(strpos($mybb->input['email'], '@aps1.net') === false)
{
    error('Invalid email domain');
}
First, when you request o support always supply as much info as you can, like this link:
Only allow members with email address from a specific domain
I'm sure that if there was a link to your previous support request, there was a quicker answer.

And for your question, mybb validate the user email in the function verify_email()
Inside the file inc/datahandlers/user.php find:
 248          // Check banned emails
 249          if(is_banned_email($user['email'], true))
 250          {
 251              $this->set_error('banned_email');
 252              return false;
 253          }
and replace with (assuming that the preg_match from the previous thread is working):
// Check banned emails
if(is_banned_email($user['email'], true) || !preg_match('#.*@aps1\.net$#si', $user['email']))
{
    $this->set_error('banned_email');
    return false;
}
Thank you to all of you who responded! It's much appreciated.

I noticed that DennisTT and dvb have suggested different ways to handle the issue.

Are both modifications necessary? Is one preferable to another?
You'll need only one modification, I've post my solution only because I somehow read an outdated version of the thread without the post of DennisTT.

I don't think that either of them is better, just choose what you want.
Possibly, in some rare situations (although I can't think about any) only my method will work.
Globally, my solution is stricter, while DennisTT's solution is simpler and readable.
Thanks for such a quick reply. I've gone with the one from Dennis simply because it is simpler.

Seems to work great!