Manual:Hooks/UserGroupsChanged

UserGroupsChanged
Available from version 1.26.0
Called after user groups are changed.
Define function:
public static function onUserGroupsChanged( User $user, array $added, array $removed, $performer, $reason, $oldUGMs, $newUGMs ) { ... }
Attach hook: In extension.json:
{
	"Hooks": {
		"UserGroupsChanged": "MediaWiki\\Extension\\MyExtension\\Hooks::onUserGroupsChanged"
	}
}
Called from: File(s): specials/SpecialUserrights.php, user/User.php
Interface: UserGroupsChangedHook.php

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


Details

edit
  • $user: User whose groups changed
  • $added: Groups added
  • $removed: Groups removed
  • $performer: User who performed the change, false if via autopromotion
  • $reason (added in MW 1.28): Reason/log comment for the change, or false if via autopromotion
  • $oldUGMs (added in MW 1.31): old user group memberships (as returned by $user->getGroupMemberships())
  • $newUGMs (added in MW 1.31): new user group memberships

Notes

edit

Added in MediaWiki 1.26 as part of the upcoming AuthManager system. Replaces the AuthPlugin::updateExternalDBGroups() method call.

See also

edit