WordPress at Your Fingertips

WP_User::add_cap() WP 1.0

Add capability and grant or deny access to capability.

{} It's a method of the class: WP_User{}

No Hooks.


null. Nothing.


$WP_User = new WP_User();
$WP_User->add_cap( $cap, $grant );
$cap(string) (required)
Capability name.
Whether to grant capability to user.


Since 2.0.0 Introduced.

Code of WP_User::add_cap() WP 5.8

public function add_cap( $cap, $grant = true ) {
	$this->caps[ $cap ] = $grant;
	update_user_meta( $this->ID, $this->cap_key, $this->caps );

From tag: Roles capabilities

No comments
    Log In