set_user_role WordPress Action Hook
The `set_user_role` hook is called after a user's role has been changed. This hook is useful for performing actions after a user's role has been changed, such as sending them an email or updating their permissions.
do_action( 'set_user_role', int $user_id , string $role , string[] $old_roles ) #
Fires after the user’s role has changed.
Parameters
- $user_id
(int)The user ID.
- $role
(string)The new role.
- $old_roles
(string[])An array of the user's previous roles.
Source
Changelog
Version | Description |
---|---|
3.6.0 | Added $old_roles to include an array of the user's previous roles. |
2.9.0 | Introduced. |