Open main menu

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": "MyExtensionHooks::onPostLoginRedirect"
	}
}

For MediaWiki ≤1.25:

$wgHooks['PostLoginRedirect'][] = 'MyExtensionHooks::onPostLoginRedirect';
Called from:File(s): specials/helpers/LoginHelper.php, specials/SpecialUserLogin.php

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

DetailsEdit

  • $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
    • success: display a return to link using $wgRedirectOnLogin if needed
    • successredirect: send an HTTP redirect using $wgRedirectOnLogin if needed

The function should return true to continue hook processing or false to abort.