WP_Role::add_cap()publicWP 2.0.0

Assign role a capability.

Method of the class: WP_Role{}

No Hooks.

Return

null. Nothing (null).

Usage

global $wp_role;
$wp_role->add_cap( $cap, $grant );
$cap(string) (required)
Capability name.
$grant(true|false)
Whether role has capability privilege.
Default: true

Changelog

Since 2.0.0 Introduced.

WP_Role::add_cap() code WP 6.5.2

public function add_cap( $cap, $grant = true ) {
	$this->capabilities[ $cap ] = $grant;
	wp_roles()->add_cap( $this->name, $cap, $grant );
}