On 12/09/2010 11:45 PM, Platonides wrote:
Clayton wrote:
Ok, this is the exact code I've added to the end of the LocalSettings.php file:
################### $wgHooks['AbortNewAccount'][] = 'noMailinator';
function noMailinator( $user, $message ) { if( !preg_match( '/@(mailinator|binkmail).com$/', $user->getEmail() )) { $message = 'One-time-use email services are forbidden on the OpenOffice.org Wiki'; return false; } return true; } ###################
I created a test account using mailinator as the authentication email address, and it went through and accepted the account creation. So... is there any way to trap or see what's happening at this stage? I can't see any reason the function doesn't work (now that I've got the right number of parenthesis). Given my (weak) knowledge of php, it seems to follow what's documented.
The lack of ampersand before $message is likely to be blocking the hook from running (PHP 5.3 is very nitpicking on this). And yes, the original code missed a ), had a ! too much and should have escaped the . inside the regex. It's also a good idea to make it case insensitive (and legal per rfc822).
It was a combination of the & and !. I looked up the exclamation thinking it was a "not", but what I found seemed to indicate it was an "if exists"... so I left it in place during the initial testing.
So, now it works exactly as I want (tested creating an account with mailinator and with a regular email account)... for now just mailinator and binkmail are blocked, but I can add more to the "or" if necessary.
Thanks to everyone for walking me through this. I've learned just a bit more about php and MediaWiki :-)
C.