Manual:Hooks/UserLoginComplete

UserLoginComplete
Available from version 1.4.0
Occurs after a user has successfully logged in via the web interface. Can be used to show custom content.
Define function:
public static function onUserLoginComplete( User &$user, string &$injectHtml, bool $direct ) { ... }
Attach hook: In extension.json:
{
	"Hooks": {
		"UserLoginComplete": "MediaWiki\\Extension\\MyExtension\\Hooks::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.


Details

edit

Use this hook to show custom content after a user has logged in via the web interface. This includes both login and signup. It's also called by the login API (but not the clientlogin API or the createaccount API) for legacy reasons.

This hook won't be called for most 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.

Before 1.42 this hook was also called when the user visited the login page with a returnto parameter while already logged in. Code that needs to run in that situation should use the PostLoginRedirect hook instead.

  • $user: the User object that was created on login
  • $injectHtml: HTML to inject after the login success message. (Setting it to a non-empty value will also prevent redirects: instead of the user being sent back to the page indicated by the returnto URL parameter, they will see a success page with $inject_html and a link to the returnto page.) (introduced in 1.13)
  • $direct: Unused, always true. Before 1.42, it was false when the hook was called in situations other than a successful login or signup; since 1.42 those don't happen anymore. (introduced in 1.28)(deprecated in 1.42)