WordPress at a glance

WP_Roles::add_cap() WP 1.0

Add capability to role.

No Hooks.

Return

Nothing (null).

Usage

$WP_Roles = new WP_Roles();
$var = $WP_Roles->add_cap( $role, $cap, $grant );
$role(string) (required)
Role name.
$cap(string) (required)
Capability name.
$grant(true/false)
Whether role is capable of performing capability.
Default: true

Code of WP Roles::add cap: wp-includes/class-wp-roles.php WP 5.2

<?php
public function add_cap( $role, $cap, $grant = true ) {
	if ( ! isset( $this->roles[ $role ] ) ) {
		return;
	}

	$this->roles[ $role ]['capabilities'][ $cap ] = $grant;
	if ( $this->use_db ) {
		update_option( $this->role_key, $this->roles );
	}
}
No comments
    Hello, !     Log In . Register