Manual:Hooks/UserLoginComplete

From MediaWiki.org
Jump to: navigation, search
UserLoginComplete
Available from version 1.4.0
Occurs after a user has successfully logged in. Can be used to show custom content after a user has logged in via the web interface.
Define function:
public static function onUserLoginComplete( User &$user, &$inject_html, $direct ) { ... }
Attach hook:

In extension.json:

{
	"Hooks": {
		"UserLoginComplete": "MyExtensionHooks::onUserLoginComplete"
	}
}

For MediaWiki ≤1.25:

$wgHooks['UserLoginComplete'][] = 'MyExtensionHooks::onUserLoginComplete';
Called from: File(s): SpecialUserlogin.php

For more information about attaching hooks, see Manual:Hooks.
For examples of extensions using this hook, see Category:UserLoginComplete extensions.

Details[edit]

  • $user: the user object that was created on login
  • $inject_html: From 1.13, any HTML to inject after the login success message.
  • $direct: (bool) Since 1.28. The hook is called directly after a successful login. This will only happen once per login. A UserLoginComplete call with direct=false can happen when the user visits the login page while already logged in.

This hook won't be called for API logins and is only intended for display purposes. Use the UserLoggedIn hook or an AuthManager provider's postAuthentication method for running backend logic on login.