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.
Login and signup links will usually set the &returnto=...
and &returntoquery=...
URL parameters so that after login / signup the user can be returned to where they were. These values are provided to this hook before redirecting, allowing extensions to change the return _target to a particular welcome page or to provide an extra query string parameter.
Extensions that change the return _target should pass the original $returnTo
and $returnToQuery
values to the _target page, which should redirect the user to the original return _target once it does whatever it needs to do. This is necessary for compatibility with other extensions depending on the return _target for their functionality, e.g. OAuth. Alternatively, you might only change the return _target after detecting a custom URL parameter provided by your extension's own workflow.
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 neededsuccessredirect
: 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)