WordPress at Your Fingertips

WP_Roles::add_cap() WP 1.0

Add capability to role.

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

No Hooks.

Return

null. Nothing.

Usage

global $wp_roles;
$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

Changelog

Since 2.0.0 Introduced.

Code of WP_Roles::add_cap() WP 5.8

<?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 );
	}
}

From tag: Roles capabilities

No comments
    Log In