add_role

Advertisement

Summery Summery

Add role, if it does not exist.

Syntax Syntax

add_role( string $role, string $display_name, array $capabilities = array() )

Parameters Parameters

$role

(Required) Role name.

$display_name

(Required) Display name for role.

$capabilities

(Optional) List of capabilities, e.g. array( 'edit_posts' => true, 'delete_posts' => false );

Default value: array()

Return Return

(WP_Role|null) WP_Role object if role is added, null if already exists.

Source Source

File: wp-includes/capabilities.php

 * @param string      $capability Capability name.
 * @param mixed       ...$args    Optional further parameters, typically starting with an object ID.
 * @return bool Whether the user has the given capability.
 */
function user_can( $user, $capability, ...$args ) {
	if ( ! is_object( $user ) ) {

Advertisement

Changelog Changelog

Changelog
Version Description
2.0.0 Introduced.

Advertisement

Leave a Reply