WP_Roles::add_cap()
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 Roles::add cap WP 5.9.3
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 ); } }