MyBB Community Forums

Full Version: Only allow members with email address from a specific domain
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
I am setting up a private discussion board for the exclusive use of our school district staff. Right now, I have the board set up so that all new users need to be approved by an admin.

My ideal situation would be to automatically restrict membership only to those people who register with an email address of [email protected] (our school system domain). Then, all they would have to do is confirm their registration from an email sent to their email address, and I would not have to manually confirm each of them.

Is this possible?
See if this helps.
In /inc/datahandlers/user.php
Find:
if(!validate_email_format($user['email']))
Replace with
if(!validate_email_format($user['email']) || !preg_match('#*@aps1\.net$#i', $user['email']))
See if that works.
ZiNgA BuRgA Wrote:See if this helps.
In /inc/datahandlers/user.php
Find:
if(!validate_email_format($user['email']))
Replace with
if(!validate_email_format($user['email']) || !preg_match('#*@aps1\.net$#i', $user['email']))
See if that works.

Thanks! I'll try it out right now. Quick question though: why is there a backslash after aps1?
Well, I tried it out, and found two problems:

1. There was the following error message:
Warning: preg_match() [function.preg-match]: Compilation failed: nothing to repeat at offset 0 in /home/teameigw/public_html/aps2/mybb/inc/datahandlers/user.php on line 217

2. I also received the message:
The email address you entered is invalid. Please enter a valid email address.

I will try the code again without the backslash, in the hope that it might help. I'll let you know!
teacherdavid Wrote:Well, I tried it out, and found two problems:

1. There was the following error message:
Warning: preg_match() [function.preg-match]: Compilation failed: nothing to repeat at offset 0 in /home/teameigw/public_html/aps2/mybb/inc/datahandlers/user.php on line 217

2. I also received the message:
The email address you entered is invalid. Please enter a valid email address.

I will try the code again without the backslash, in the hope that it might help. I'll let you know!

Well, I tried it without the "\" but I got the same errors. Any suggestions?
Looks like I made a mistake in the above replacement - sorry.

Try this one:
if(!validate_email_format($user['email']) || !preg_match('#.*@aps1\.net$#si', $user['email']))
The backslash is there because a period "." has a special meaning in regex. The backslash nullifies its special meaning.
I'd almost suggest a plugin instead of modifying core files. Check out the member_register_start and member_register_end hooks.
Yes I would as well, but it's much quicker to write a code modification than it is to write up a plugin.
ZiNgA BuRgA Wrote:Yes I would as well, but it's much quicker to write a code modification than it is to write up a plugin.

[Da vinci code]
But oh so sweet... the smell of plugins.
[/Da vinci code]
Pages: 1 2