Script to add user to MediaWiki
Posted
by Marquis Wang
on Stack Overflow
See other posts from Stack Overflow
or by Marquis Wang
Published on 2009-05-29T23:56:55Z
Indexed on
2010/06/12
8:23 UTC
Read the original article
Hit count: 318
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!
© Stack Overflow or respective owner