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.


Top ↑

Source

File: wp-includes/class-wp-user.php

View on Trac



Top ↑

Changelog

Changelog
VersionDescription
3.6.0Added $old_roles to include an array of the user's previous roles.
2.9.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.