WP_Role::__construct() WordPress Method

The WP_Role::__construct() function is used to create a new role object. It takes two arguments: the role name and the capabilities array. The role name is a string that must be unique. The capabilities array is an associative array of capability names and booleans.

WP_Role::__construct( string $role, bool[] $capabilities ) #

Constructor – Set up object properties.


Description

The list of capabilities must have the key as the name of the capability and the value a boolean of whether it is granted to the role.


Top ↑

Parameters

$role

(string)(Required)Role name.

$capabilities

(bool[])(Required)Array of key/value pairs where keys represent a capability name and boolean values represent whether the role has that capability.


Top ↑

Source

File: wp-includes/class-wp-role.php

	public function __construct( $role, $capabilities ) {
		$this->name         = $role;
		$this->capabilities = $capabilities;
	}


Top ↑

Changelog

Changelog
VersionDescription
2.0.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.