Manual:Hooks/UserLoadFromSession
File:OOjs UI icon alert-destructive.svg | <translate> This feature was removed from MediaWiki core in version <tvar name=ver>1.34.0</tvar> (after being deprecated in <tvar name=4>1.27.0</tvar>).</translate> <translate> Please see <tvar name=page>MediaWiki\Session\SessionProvider</tvar> for an alternative way to use this feature.</translate> |
UserLoadFromSession | |
---|---|
<translate> Available from <tvar name=1><translate> version <tvar </tvar></translate> <translate> Removed in <tvar name=1><translate> version <tvar (Gerrit change 518326)</tvar></translate> Called to authenticate users on external/environmental means. | |
<translate> Define function:</translate> | public static function onUserLoadFromSession( $user, &$result ) { ... }
|
<translate> Attach hook:</translate> | <translate> In <tvar name=1>extension.json</tvar>:</translate>
{
"Hooks": {
"UserLoadFromSession": "MediaWiki\\Extension\\MyExtension\\Hooks::onUserLoadFromSession"
}
}
|
<translate> Called from:</translate> | <translate> File(s):</translate> user/User.php |
<translate> Interface:</translate> | UserLoadFromSessionHook.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:UserLoadFromSession extensions</tvar>.</translate>
Details
$user
: User object being loaded&$result
: set this to a boolean value to abort the normal authentication process
This hook replaces AutoAuthenticate, which has been removed in 1.13.
An extension can use this hook to fill in the data of the User object $user from an external session. This is typically used in Authentication extensions.
When the authentication should continue undisturbed after the hook was executed, do not touch $result. When the normal authentication should not happen (e.g., because $user is completely initialized), set $result to any boolean value.
In any case, return true
.
See the talk page for sample code for this hook.