Manual:Hooks/UserGetRightsRemove

UserGetRightsRemove
Available from version 1.32.0 (Gerrit change 462157)
Dynamically removes from a user the rights implied by their group membership
Define function:
public static function onUserGetRightsRemove( User $user, array &$aRights ) { ... }
Attach hook: In extension.json:
{
	"Hooks": {
		"UserGetRightsRemove": "MediaWiki\\Extension\\MyExtension\\Hooks::onUserGetRightsRemove"
	}
}
Called from: File(s): Permissions/PermissionManager.php
Function(s): getUserPermissions
Interface: UserGetRightsRemoveHook.php

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


Details edit

  • $user: User to get rights for
  • &$rights: Current rights

Called in User::getRights(), after the UserGetRights hook has finished. It can be used to remove rights in a safe way (which would not be possible in UserGetRights as there's no way to guarantee that the next hook handler won't re-add the right). Therefore, UserGetRightsRemove handlers should never add rights, only remove them.

See also edit