Manual:Hooks/UserEffectiveGroups

From MediaWiki.org
Jump to navigation Jump to search
UserEffectiveGroups
Available from version 1.11.0
Dynamically add or remove to the default user groups provided by the database table User groups table
Define function:
public static function onUserEffectiveGroups( &$user, &$aUserGroups ) { ... }
Attach hook:

In extension.json:

{
	"Hooks": {
		"UserEffectiveGroups": "MyExtensionHooks::onUserEffectiveGroups"
	}
}

For MediaWiki ≤1.25:

$wgHooks['UserEffectiveGroups'][] = 'MyExtensionHooks::onUserEffectiveGroups';
Called from:File(s): User.php

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

Use cases[edit]

The UserEffectiveGroups hook lets MediaWiki installations filter and add to the list of user groups stored in the MediaWiki database. For example, one might wish to synchronize the user groups with the host operating system or with a third party package.

Usage[edit]

At the time of invocation $aUserGroups is populated with the groups assigned to the user by the User groups table. Functions attached to this hook change the groups by adding or removing array elements.

Hooks should always return true so as not to block other functions attached to this hook.

See also[edit]