Topic on Project:Support desk

Allow account creation only from specific email domains.

MarkJurgens (talkcontribs)

I'd like to allow teachers from my school board to create an account on our wiki, but ONLY if they have an email addresses from a specific domain. (Ex. The end result would be only teachers from specific school boards would be able to create accounts and edit.

An array to add multiple school board domains would be great.

Any ideas? Thanks!

MarkAHershberger (talkcontribs)

This is easy to do by using the AbortNewAccount hook. Something like the following (untested, but based on code I use):

function abortOnBadDomain($user, &$message) {
	global $wgRequest;
	$allowedDomains = array( "", "" );
	$email = $wgRequest->getText( 'wpEmail' );
	$emailSplitList = explode("@", $email, 2);

	if ( isset( $emailSplitList[1] ) ) {
		foreach( $allowedDomains as $domain ) {
			if ( $emailSplitList[1] === $domain ) ) {
				return true;
	$message = "Domain blocked";

	return false;
$wgHooks['AbortNewAccount'][] = 'abortOnBadDomain';
MarkJurgens (talkcontribs)

Thanks Mark,

I may have sounded like a programmer in my initial request, and I've got a good handle on configuring Mediawiki, so excuse my ignorance:

Where do I put this code?

On another note, are there a way to find a coder(s) who might want to help me with an educational project? I can float server costs but developer might tank my non-existent budget. :)

Thanks again! P.s. Nice blog.

MarkAHershberger (talkcontribs)

You can put the code at the bottom of your LocalSettings.php file. It should work there. Let me know if you run into problems with it.

I'm not sure how to find a volunteer coder, but you might find someone who has some interest, or who can offer you pointers by writing about your project on mail:mediawiki-l.


Reply to "Allow account creation only from specific email domains."