wppaste
WordPress

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:

  1. do_action( remove_user_role )actionline 603 (+18 into the body)

    Fires immediately after a role as been removed from a user.

Uses · 4

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.

  1. 6.7.7
  2. 6.8.8
  3. 6.9.7
  4. 7.0.4
  5. 7.1.0

Signature, return type and hooks compared across 5 parsed releases.

About this page

Parsed data
Generated from the wordpress-develop 6.9.7 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.