Glossary Term
add_role()
add_role() — Adds a role, if it does not exist. The list of capabilities can be passed either as a numerically indexed array of capability names, or an associative array of boolean values keyed by the capability name. To explicitly deny the role a capability, set the value for that capability to false. Examples: // Add a role that can edit posts. add_role( ‘custom_role’, ‘Custom Role’, array( ‘read’, ‘edit_posts’, ) ); Or, using an associative array: // Add a role that can edit posts but explicitly cannot not delete them. add_role( ‘custom_role’, ‘Custom Role’, array( ‘read’ => true, ‘edit_posts’ => true, ‘delete_posts’ => false, ) );
Inputs: $role (string): Role name. $display_name (string): Display name for role. $capabilities (array<string,bool>|array<int,string>): Capabilities to be added to the role. Default empty array.
Returns WP_Role|null: WP_Role object, if the role is added.
Term Connections
Explore related terms connected by shared tags, shared categories, and relationship phrases. This map loads only when it comes into view.
Loading term connections…
