set_user_role
Fires after the user's role has changed.
Использование
add_action( 'set_user_role', 'wp_kama_set_user_role_action', 10, 3 ); /** * Function for `set_user_role` action-hook. * * @param int $user_id The user ID. * @param string $role The new role. * @param string[] $old_roles An array of the user's previous roles. * * @return void */ function wp_kama_set_user_role_action( $user_id, $role, $old_roles ){ // action... }
- $user_id(int)
- The user ID.
- $role(строка)
- The new role.
- $old_roles(string[])
- An array of the user's previous roles.
Список изменений
С версии 2.9.0 | Введена. |
С версии 3.6.0 | Added $old_roles to include an array of the user's previous roles. |
Где вызывается хук
wp-includes/class-wp-user.php 655
do_action( 'set_user_role', $this->ID, $role, $old_roles );
Где используется хук в WordPress
wp-includes/default-filters.php 123
add_action( 'set_user_role', 'wp_cache_set_users_last_changed' );