WordPress at a glance
function is not described

WP_Role::add_cap() public WP 2.0.0

Assign role a capability.

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

No Hooks.

Return

null. Nothing.

Usage

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

Changelog

Since 2.0.0 Introduced.

Code of WP_Role::add_cap() WP 5.7.2

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