Manual:Hooks/UserEffectiveGroups

From Linux Web Expert

UserEffectiveGroups
<translate> Available from <tvar name=1><translate> version <tvar </tvar></translate>
Dynamically add or remove to the default user groups provided by the database table User groups table
<translate> Define function:</translate>
public static function onUserEffectiveGroups( &$user, &$aUserGroups ) { ... }
<translate> Attach hook:</translate> <translate> In <tvar name=1>extension.json</tvar>:</translate>
{
	"Hooks": {
		"UserEffectiveGroups": "MediaWiki\\Extension\\MyExtension\\Hooks::onUserEffectiveGroups"
	}
}
<translate> Called from:</translate> <translate> File(s):</translate> User.php
<translate> Interface:</translate> UserEffectiveGroupsHook.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:UserEffectiveGroups extensions</tvar>.</translate>

Use cases

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

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.

See also