MyBB Community Forums

Full Version: restrict email domain at registration
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi there,

I'm new to MyBB and testing functionalty as I have had little help from other boards on this request.

I love what I see so far as it is so easy to use in comparison to others. I do plan on learning php if this is succesful.

I need to lock down the email on registration to a single domain. I also need to have the user change password every 60 days and their account set to inactive until they confirm the password change via an email sent to their registered address.

The only thing others cant or wont do is setting the account to inactive after a password change.

Is this possible?
The following "plug-in" should do the magic for you.

<?php
define('THE_DOMAIN', 'sentoweb.com');

// Registration 
$plugins->add_hook('datahandler_user_validate', 'DomainRestrict_registration');

function DomainRestrict_info(){
    return array(
        "name"            => "Restrict registration",
        "description"    => "",
        "website"        => "http://mybbtutorials.com",
        "author"        => "Ervin Czeczi",
        "authorsite"    => "http://sentoweb.com",
        "guid" => "",
        "version" => "1.0",
        "compatibility" => "16*"
    );
}

function DomainRestrict_registration($data) {
	$email = explode("@", $data->data['email']);
	
	if (strtolower($email[1])!=THE_DOMAIN) {
		$data->set_error('Only emails from the '.THE_DOMAIN.' domain are allowed to register on this forum');
	}
}
?>

Save this as DomainRestrict.php in inc/plugins. Don't forget to replace sentoweb.com with the domain of your choice.
That worked perfectly, thanks.

Can I set the user password to expire after a set number of days?
I am not aware of such plug-in but I think that is something that more people could use, including myself. I might have time to code such thing today, if not then remind me in a few days.

What I have in mind is a plug-in displaying a warning message to the user a few days before the password expires, and if the password already expired force the user to change it. This is actually a very useful feature to have security-wise, however you must be careful not to annoy users with a password reset request every few days.