add_user_role

add_user_role

Appears in: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , ,
Hook Type: action
See hook in action

See hook in core

Displaying hooks found in version: wordpress-6.7

do_action('add_user_role') is found 2 times:

  • /wp-includes/class-wp-user.php line 567
    		 *
    		 * @param int    $user_id The user ID.
    		 * @param string $role    The new role.
    		 */
    		do_action( 'add_user_role', $this->ID, $role );
    	}
    
    	/**
    	 * Removes role from user.
    	 *
    	 * @since 2.0.0
    
  • /wp-includes/class-wp-user.php line 642
    		}
    
    		if ( $role && ! in_array( $role, $old_roles, true ) ) {
    			/** This action is documented in wp-includes/class-wp-user.php */
    			do_action( 'add_user_role', $this->ID, $role );
    		}
    
    		/**
    		 * Fires after the user's role has changed.
    		 *
    		 * @since 2.9.0
    

See this hook used in plugins: