This is actually what I tried first.
The problem is that User::addGroup does security checks and checks a "addable" array that is a list of groups you are allowed to add someone too. So non sysops can not add add themselves to the sysop group.
On Jun 20, 2011, at 6:52 AM, Ćukasz Garczewski wrote:
On Mon, Jun 20, 2011 at 5:29 AM, Adam Meyer meyer7@mindspring.com wrote:
It looks like the way to do it would be to run a query like so:
$user = User::newFromName( $userName );
$dbw = wfGetDB( DB_MASTER );
$dbw->insert( 'user_groups', array( 'ug_user' => $user->getID(), 'ug_group' => 'bot', ), 'User::addGroup', array( 'IGNORE' ) );
Never run queries on the database when you can use wrapper methods. Use this instead:
$user = User::newFromName( $name ); $user->addGroup( 'sysop' );
-- Lucas 'TOR' Garczewski Community Engineer tor@wikia-inc.com
MediaWiki-l mailing list MediaWiki-l@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-l