WP_User::add_cap()
Add capability and grant or deny access to capability.
{} It's a method of the class: WP_User{}
No Hooks.
Return
null
. Nothing.
Usage
$WP_User = new WP_User(); $WP_User->add_cap( $cap, $grant );
- $cap(string) (required)
- Capability name.
- $grant(true|false)
- Whether to grant capability to user.
Default: true
Changelog
Since 2.0.0 | Introduced. |
Code of WP_User::add_cap() WP User::add cap WP 5.9.3
public function add_cap( $cap, $grant = true ) { $this->caps[ $cap ] = $grant; update_user_meta( $this->ID, $this->cap_key, $this->caps ); $this->get_role_caps(); $this->update_user_level_from_caps(); }