I'm afraid this is broken for the newest version of MediaWiki; I looked at trying to fix it but am not all that well versed in php. Seems that the wfMessage needs to be put in, but also I can't get $user->getEmail() to produce results.
Extension talk:EmailDomainCheck
Hm, it looks like a PreAuthenticationProvider needs to be implemented - https://www.mediawiki.org/wiki/Manual:Hooks/AbortNewAccountManual:Hooks/AbortNewAccount
I've created a small extension that works in newer versions: https://github.com/Insolitu/RestrictEmailDomain
It's broken for me too. However, I've tried Sdeaki's extension and it works pretty good although, I do get:
Warning: Cannot modify header information - headers already sent by (output started at \mediawiki\extensions\RestrictEmailDomain\RestrictEmailDomain_body.php:15) in \mediawiki\includes\WebResponse.php on line 42
Sdeaki - fantastic, and thank you!
Extension:EmailDomainCheck works on MediaWiki 1.29. I put in a fix in the error path (when a user attempts to create an account with an unsupported domain) by replacing wfMsgHtml() with wfMessage()
Hi, Can I use this program to restrict registration to one or a few domains, but allow certain users with emails outside these domains editing privileges anyway?
For example: restrict my wiki to @illinois.edu domains, but allow eddie@ftu.edu as well?
Thanks!
See Mlu's awesome answer below
This post was posted by Gregology~mediawikiwiki, but signed as Gregology.
I got a question tho, can I use this if I want to allow multiple domains?
you have to change the code like follows:
replace:
$wgEmailDomain = "foo.com";
by:
$wgEmailDomain=array("news.com","foo.com","bar.com"); //Array of allowed domains
and
if ($host == $wgEmailDomain){
by
if in_array($host,$wgEmailDomain){
regards, mlu
I got this error using the array...
PHP Parse error: syntax error, unexpected 'in_array' (T_STRING), expecting '('
relating to the line
if in_array($host,$wgEmailDomain){
Grateful for any ideas...
This post was posted by Antstamper~mediawikiwiki, but signed as Antstamper.
I fixed this with...
if (in_array ( $host , $wgEmailDomain )){
This post was posted by Antstamper~mediawikiwiki, but signed as Antstamper.
I added this extension to my mediawiki and it is perfect.
But a lot of times when I'm just browsing through my wiki at the top of the page the following sentence is shown. "Your email address must end in" It is on top of the logo, the wiki is fine and usable but it annoys me. Does anyone has this too? And preferably knows how to solve this.
Note: I changed the following for sake of being able to check on multiple domains
function efEmailDomainCheck( $user, &$error ) {
global $wgEmailDomain;
if ( isset( $wgEmailDomain ) ) {
list( $name, $host ) = explode( "@", $user->getEmail() );
//if ( efEndsWith( $host, $wgEmailDomain ) ) { // use this line to allow subdomains of $wgEmailDomain
if (in_array ( $host , $wgEmailDomain )){
//if ( $host == $wgEmailDomain ) {
return true;
} else {
$error = wfMsgHtml( 'emaildomaincheck-error', join(" or ",$wgEmailDomain) );
return false;
}
}
}
In my LocalSettings.php I use this line:
$wgEmailDomain = array("domain1.com","domain2.com","domain3.com"); //Array of allowed domains
When I look into the source of a shown page it tells me this in the first line. Does anyone have a tip?
Your email address must end in <!DOCTYPE html>
This works great, but it does not seem to kick in if the user goes to the change email page, and submits an unwanted email domain.
Is there a way to make this work with the change email page, or disable the change email page?
Otherwise a staff person could create a new account with an approved email domain, but using a fake name, then change the email using the change email page to an outside domain, and then we have no idea who they are.
Hello,
I hope I will not be off-topic with my question/issue...
Since the teachers of my university do not want to have their lectures to be public, I had to restrict the access to even readers (before only editors had to be registered, now this includes also readers, unfortunately). However, since the access requests of the students will probably (and hopefully) skyrocket, I found about the EmailDomainCheck extension that I setup on my test wiki.
However I noticed that if in LocalSettings.php I passed: $wgGroupPermissions['*']['createaccount'] = false;
to
$wgGroupPermissions['*']['createaccount'] = true;
People had just to give any e-mail address (even a non-existing one), having the correct domaine name and they would be registered with a welcome message and already logged in, thus bypassing the EmailDomainCheck extension.
Is there a way to restrict the account creation so that people have to click a button that sends the login credential to the mentioned e-mail address?
Thanks in advance and best regards, pdeli
++++
Hi, great extension. Does anyone know if i would be possible to automatically give users with a specified domain name a different restriction level from the default? That is, I want only users with emails from a certain domain name to be able to edit one page on my wiki.