Manual:Hooks/PostLoginRedirect

From Linux Web Expert

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

<translate> For more information about attaching hooks, see <tvar name=1>Manual:Hooks </tvar>.</translate>
<translate> For examples of extensions using this hook, see <tvar name=cat>Category:PostLoginRedirect extensions</tvar>.</translate>

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

Details

  • $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

  • 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)