Automatically Block New Users

From WinWolf3D/WDC

For MediaWiki 1.5.2.

If you block guest users from editing pages, spammers will start making junk user accounts. Follow this tutorial to automatically block new user accounts and mark them as "awaiting admin approval".

I recommend installing the NewUserNotif mod with this tutorial. You can get the mod here. Be sure to grab the right version.

Here are the settings I have for my notification email.

Keeps everything simple and allows you to authorize the user via a link in the email.

includes/SpecialUserlogin.php

  • Open includes/SpecialUserlogin.php
  • Find:
function &initUser( &$u ) {
  • Find in function &initUser:
$u->setOption( 'rememberpassword', $r );
  • Add AFTER (you have two choices).

This choice causes the sysop user to block the spam account and does not log the action.

// The sysop will block new users automagically!
$blockinguserid = $u->mId;
$dbr =& wfGetDB( DB_SLAVE );
$s = $dbr->selectRow( 'user_groups', array( 'ug_user' ),
	array( 'ug_group' => 'sysop' ), 'SpecialUserlogin::initUser' );
if ( $s !== false ) {
	$blockinguserid = $s->ug_user;
}
// Block the new user.
$block = new Block( $u->mName, $u->mId, $blockinguserid, 'Blocked.  Awaiting admin approval.', 
	wfTimestampNow() );
$block->insert();
}
  • Close file