WP_Role::add_cap()
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() WP Role::add cap code WP 6.7.1
public function add_cap( $cap, $grant = true ) { $this->capabilities[ $cap ] = $grant; wp_roles()->add_cap( $this->name, $cap, $grant ); }