add_user_role
Fires immediately after the user has been given a new role.
Usage
add_action( 'add_user_role', 'wp_kama_add_user_role_action', 10, 2 );
/**
* Function for `add_user_role` action-hook.
*
* @param int $user_id The user ID.
* @param string $role The new role.
*
* @return void
*/
function wp_kama_add_user_role_action( $user_id, $role ){
// action...
}
- $user_id(int)
- The user ID.
- $role(string)
- The new role.
Changelog
| Since 4.3.0 | Introduced. |
Where the hook is called
add_user_role
wp-includes/class-wp-user.php 575
do_action( 'add_user_role', $this->ID, $role );
wp-includes/class-wp-user.php 650
do_action( 'add_user_role', $this->ID, $role );
Where the hook is used in WordPress
wp-includes/default-filters.php 133
add_action( 'add_user_role', 'wp_cache_set_users_last_changed' );