Manual:Hooks/UserRights
File:OOjs UI icon alert-destructive.svg | <translate> This feature was removed from MediaWiki core in version <tvar name=ver>1.34.0</tvar> (after being deprecated in <tvar name=4>1.26.0</tvar>).</translate> <translate> Please see <tvar name=page>UserGroupsChanged</tvar> for an alternative way to use this feature.</translate> |
UserRights | |
---|---|
<translate> Available from <tvar name=1><translate> version <tvar </tvar></translate> <translate> Removed in <tvar name=1><translate> version <tvar (Gerrit change 518324)</tvar></translate> Called after a user's group memberships are changed | |
<translate> Define function:</translate> | public static function onUserRights( $user, array $add, array $remove ) { ... }
|
<translate> Attach hook:</translate> | <translate> In <tvar name=1>extension.json</tvar>:</translate>
{
"Hooks": {
"UserRights": "MediaWiki\\Extension\\MyExtension\\Hooks::onUserRights"
}
}
|
<translate> Called from:</translate> | <translate> File(s):</translate> specials/SpecialUserrights.php |
<translate> Interface:</translate> | UserRightsHook.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:UserRights extensions</tvar>.</translate>
Details
- $user: User or UserRightsProxy object that was changed
- $add: Array of strings corresponding to groups added
- $remove: Array of strings corresponding to groups removed
If the $user parameter was a UserRightsProxy object, this user rights change was performed on a different wiki. This means that you might be mislead into identifying a user based on information such a name or ID because they do not share that attribute on the local wiki - it will almost certainly point to a different user entirely.
Additionally, the $user parameter could be a CentralAuthGroupMembershipProxy object from Extension:CentralAuth in the case of a global user rights change. The information given by this object represents a global account shared across wikis, and the ID will not match the attached local account IDs.
See also
- UserGroupsChanged - replaces this hook
- UserGetRights - provide user rights dynamically