Jump to content

Manual:Hooks/UserrightsChangeableGroups

From mediawiki.org
UserrightsChangeableGroups
Available from version 1.14.0
Removed in version 1.16.0
Called after the list of groups that can be manipulated via Special:UserRights is populated, but before it is returned.
Define function:
public static function onUserrightsChangeableGroups( $userrights, $user, $addergroups, &$groups ) { ... }
Attach hook: In extension.json:
{
	"Hooks": {
		"UserrightsChangeableGroups": "MediaWiki\\Extension\\MyExtension\\Hooks::onUserrightsChangeableGroups"
	}
}
Called from: File(s): SpecialUserrights.php
Interface: UserrightsChangeableGroupsHook.php

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

Details

[edit]
  • $userrights: The UserrightsForm object.
  • $user: The user object of the current user.
  • $addergroups: Array of groups that the user is in.
  • $groups: Array of groups that are changeable by this interface. Change this variable to modify that list.
    • $groups is in the format of array( 'add' => array( addablegroups ), 'remove' => array( removeablegroups ), 'add-self' => array( groups addable to self), 'remove-self' => array( groups removable from self ) ).

This hook allows extensions to change what groups a user may add or remove from other users or themselves, independent from user rights or configuration variables. A possible use could be to prevent users that are not in a certain group but have full userrights access from adding or removing that specific group.

Only the $groups variable is passed by reference, so modification of other aspects of the Userrights form or the current user cannot be achieved with this hook.