wpseek.com
A WordPress-centric search engine for devs and theme authors



add_role › WordPress Function

Since2.0.0
Deprecatedn/a
add_role ( $role, $display_name, $capabilities = array() )
Parameters: (3)
  • (string) $role Role name.
    Required: Yes
  • (string) $display_name Display name for role.
    Required: Yes
  • (bool[]) $capabilities List of capabilities keyed by the capability name, e.g. array( 'edit_posts' => true, 'delete_posts' => false ).
    Required: No
    Default: array()
Returns:
  • (WP_Role|void) WP_Role object, if the role is added.
Defined at:
Codex:

Adds a role, if it does not exist.



Source

function add_role( $role, $display_name, $capabilities = array() ) {
	if ( empty( $role ) ) {
		return;
	}

	return wp_roles()->add_role( $role, $display_name, $capabilities );
}