Manual:Hooks/UserLoginComplete

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, string &$injectHtml, bool $direct ) { ... }
Attach hook:

In extension.json:

{
	"Hooks": {
		"UserLoginComplete": "MyExtensionHooks::onUserLoginComplete"
	}
}
Called from:File(s): specials/SpecialUserLogin.php
Interface:UserLoginCompleteHook.php

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

DetailsEdit

  • $user: the User object that was created on login
  • $injectHtml: HTML to inject after the login success message (introduced¬†in 1.13)
  • $direct: 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. (introduced¬†in 1.28)

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 MediaWiki\Auth\PreAuthenticationProvider::postAuthentication() method for running backend logic on login.