Open main menu

Manual:Hooks/UserLoadFromSession

UserLoadFromSession
Available from version 1.13.0
Removed in version 1.34.0
Called to authenticate users on external/environmental means.
Define function:
public static function onUserLoadFromSession( $user, &$result ) { ... }
Attach hook:

In extension.json:

{
	"Hooks": {
		"UserLoadFromSession": "MyExtensionHooks::onUserLoadFromSession"
	}
}

For MediaWiki ≤1.25:

$wgHooks['UserLoadFromSession'][] = 'MyExtensionHooks::onUserLoadFromSession';
Called from:File(s): user/User.php

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

DetailsEdit

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

See alsoEdit