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.

Return

null. Nothing.

Usage

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

Changelog

Since 2.0.0 Introduced.

Code of WP_User::add_cap() WP 5.8

<?php
public function add_cap( $cap, $grant = true ) {
	$this->caps[ $cap ] = $grant;
	update_user_meta( $this->ID, $this->cap_key, $this->caps );
	$this->get_role_caps();
	$this->update_user_level_from_caps();
}

From tag: Roles capabilities

No comments
    Log In