WP_User::remove_cap()publicWP 2.0.0

Removes capability from user.

Method of the class: WP_User{}

No Hooks.

Return

null. Nothing (null).

Usage

$WP_User = new WP_User();
$WP_User->remove_cap( $cap );
$cap(string) (required)
Capability name.

Changelog

Since 2.0.0 Introduced.

WP_User::remove_cap() code WP 6.5.2

public function remove_cap( $cap ) {
	if ( ! isset( $this->caps[ $cap ] ) ) {
		return;
	}
	unset( $this->caps[ $cap ] );
	update_user_meta( $this->ID, $this->cap_key, $this->caps );
	$this->get_role_caps();
	$this->update_user_level_from_caps();
}