WP_User::remove_role( string $role )
- Since
- 2.0.0
- Source
wp-includes/class-wp-user.php:585
Removes role from user.
Parameters
$rolestring- Role name.
Hooks fired · 1
One hook fires while WP_User::remove_role() runs, in this order:
- do_action( remove_user_role )actionline 603 (+18 into the body)
Fires immediately after a role as been removed from a user.
Uses · 4
- update_user_meta()Updates user meta field based on user ID.
- do_action()Calls the callback functions that have been added to an action hook.
- WP_User::get_role_caps()Retrieves all of the capabilities of the user's roles, and merges them with individual user capabilities.
- WP_User::update_user_level_from_caps()Updates the maximum user level for the user.
Source
public function remove_role( $role ) { if ( ! in_array( $role, $this->roles, true ) ) { return; } unset( $this->caps[ $role ] ); update_user_meta( $this->ID, $this->cap_key, $this->caps ); $this->get_role_caps(); $this->update_user_level_from_caps(); /** * Fires immediately after a role as been removed from a user. * * @since 4.3.0 * * @param int $user_id The user ID. * @param string $role The removed role. */ do_action( 'remove_user_role', $this->ID, $role ); }History
Introduced in 2.0.0. Unchanged from 6.7.7 through 7.1.0.
Signature, return type and hooks compared across 5 parsed releases.
About this page
- Parsed data
- Generated from the wordpress-develop 7.0.4 tag, from
src/wp-includes/class-wp-user.php, and regenerated for each WordPress release so it tracks the code rather than a snapshot of it. - Corrections
- Something wrong on this page? Report it and it gets fixed in the next regeneration.