Manual:Hooks/PostLoginRedirect

PostLoginRedirect
Available from version 1.24.0
Occurs after signing up or logging in, allows for interception of redirect.
Define function:
public static function onPostLoginRedirect( &$returnTo, &$returnToQuery, &$type ) { ... }
Attach hook: In extension.json:
{
	"Hooks": {
		"PostLoginRedirect": "MediaWiki\\Extension\\MyExtension\\Hooks::onPostLoginRedirect"
	}
}
Called from: File(s): specials/helpers/LoginHelper.php, specials/SpecialUserLogin.php
Interface: PostLoginRedirectHook.php

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

Called after logging in or signing up through the web interface.

Details edit

  • $returnTo: The page name to return to, as a string
  • $returnToQuery: array of url parameters, mapping parameter names to values
  • $type: type of login redirect as string, which can be one of:
    • error: display a return to link ignoring $wgRedirectOnLogin
    • signup: display a return to link using $wgRedirectOnLogin if needed (used after signup)
    • success: display a return to link using $wgRedirectOnLogin if needed
    • successredirect: send an HTTP redirect using $wgRedirectOnLogin if needed

See also edit

  • UserLoggedIn - a hook that always runs after login, regardless of whether it's done via web or API
  • CentralAuthPostLoginRedirect - the replacement for this hook when using CentralAuth (which needs to set its own returnto parameters to do central login, returns to the target provided via CentralAuthPostLoginRedirect after central login is done)