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_role() | Add role name with capabilities to list. |
Add role, if it does not exist.
(string) (Required) Role name.
(string) (Required) Display name for role.
(bool[]) (Optional) List of capabilities keyed by the capability name, e.g. array( 'edit_posts' => true, 'delete_posts' => false ).
Default value: array()
(WP_Role|null) WP_Role object if role is added, null if already exists.
File: wp-includes/capabilities.php
function add_role( $role, $display_name, $capabilities = array() ) { if ( empty( $role ) ) { return; } return wp_roles()->add_role( $role, $display_name, $capabilities ); }
Version | Description |
---|---|
2.0.0 | Introduced. |
© 2003–2019 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/functions/add_role