Script to add user to MediaWiki
- by Marquis Wang
I'm trying to write a script that will create a user in MediaWiki, so that I can run a batch job to import a series of users.
I'm using mediawiki-1.12.0.
I got this code from a forum, but it doesn't look like it works with 1.12 (it's for 1.13)
$name = 'Username'; #Username (MUST start with a capital letter)
$pass = 'password'; #Password (plaintext, will be hashed later down)
$email = 'email'; #Email (automatically gets confirmed after the creation process)
$path = "/path/to/mediawiki";
putenv( "MW_INSTALL_PATH={$path}" );
require_once( "{$path}/includes/WebStart.php" );
$pass = User::crypt( $pass );
$user = User::createNew( $name, array( 'password' => $pass, 'email' => $email ) );
$user->confirmEmail();
$user->saveSettings();
$ssUpdate = new SiteStatsUpdate( 0, 0, 0, 0, 1 );
$ssUpdate->doUpdate();
Thanks!