Uses
Uses | Description |
---|---|
wp-includes/capabilities.php: wp_roles() | Retrieves the global WP_Roles instance and instantiates it if necessary. |
wp-includes/class-wp-roles.php: WP_Roles::add_cap() | Add capability to role. |
Assign role a capability.
(string) (Required) Capability name.
(bool) (Optional) Whether role has capability privilege.
Default value: true
Changing the capabilities of a role is persistent, meaning the added capability will stay in effect until explicitly revoked.
This setting is saved to the database (in table wp_options, field wp_user_roles), so it might be better to run this on theme/plugin activation.
File: wp-includes/class-wp-role.php
public function add_cap( $cap, $grant = true ) { $this->capabilities[ $cap ] = $grant; wp_roles()->add_cap( $this->name, $cap, $grant ); }
Version | Description |
---|---|
2.0.0 | Introduced. |
© 2003–2019 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/classes/wp_role/add_cap