A WordPress-centric search engine for devs and theme authors



add_role ›

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
  • (array) $capabilities List of capabilities, e.g. array( 'edit_posts' => true, 'delete_posts' => false );
    Required: No
    Default: array()
Returns:
  • (WP_Role|null) WP_Role object if role is added, null if already exists.
Defined at:
Codex:

Add 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 );
}