Manual:Hooks/LocalUserCreated

From Linux Web Expert

LocalUserCreated
<translate> Available from <tvar name=1><translate> version <tvar </tvar></translate>
Called immediately after a local user has been created and saved to the database
<translate> Define function:</translate>
public static function onLocalUserCreated( $user, $autocreated ) { ... }
<translate> Attach hook:</translate> <translate> In <tvar name=1>extension.json</tvar>:</translate>
{
	"Hooks": {
		"LocalUserCreated": "MediaWiki\\Extension\\MyExtension\\Hooks::onLocalUserCreated"
	}
}
<translate> Called from:</translate> <translate> File(s):</translate> auth/AuthManager.php
<translate> Interface:</translate> LocalUserCreatedHook.php

<translate> For more information about attaching hooks, see <tvar name=1>Manual:Hooks </tvar>.</translate>
<translate> For examples of extensions using this hook, see <tvar name=cat>Category:LocalUserCreated extensions</tvar>.</translate>


Details

  • $user - User object for the created user
  • $autocreated - Boolean, whether this was an auto-creation. Note if your wiki uses CentralAuth this will always be true.

Notes

Added in MediaWiki 1.26 as part of the AuthManager system. Replaces the AuthPlugin::initUser() method call and the AddNewAccount and AuthPluginAutoCreate hooks.

Extensions which implement their own authentication provider might want to use AuthManager::autoCreatedAccount and AuthManager::postAccountCreation instead, which are similar but have access to more information. (Note that postAccountCreation is called significantly later in the process, after secondary authentication providers have finished.)

Changes which are not immediately required for database consistency should probably be deferred; see Database transactions .

If $wgAutoCreateTempUser is active, this hook is also called when a temporary account is automatically created for a logged-out user.


See also