WP_User::remove_role( string $role )

Remove role from user.

Description Description

Parameters Parameters


(string) (Required) Role name.

Top ↑

Source Source

File: wp-includes/class-wp-user.php

	public function remove_role( $role ) {
		if ( !in_array($role, $this->roles) )
		unset( $this->caps[$role] );
		update_user_meta( $this->ID, $this->cap_key, $this->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 );

Top ↑

Changelog Changelog

Version Description
2.0.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.