WordPress как на ладони
Недорогой хостинг для сайтов на WordPress: wordpress.jino.ru
функция не описана

WP_Roles::add_role() public WP 2.0.0

Add role name with capabilities to list.

Updates the list of roles, if the role doesn't already exist.

The capabilities are defined in the following format array('read'=> true ); To explicitly deny a role a capability you set the value for that capability to false.

{} Это метод класса: WP_Roles{}

Хуков нет.

Возвращает

WP_Role/null. WP_Role object, if role is added.

Использование

global $wp_roles;
$wp_roles->add_role( $role, $display_name, $capabilities );
$role(строка) (обязательный)
Role name.
$display_name(строка) (обязательный)
Role display name.
$capabilities(true/false[])
List of capabilities keyed by the capability name, e.g. array( 'edit_posts' => true, 'delete_posts' => false ).
По умолчанию: array()

Список изменений

С версии 2.0.0 Введена.

Код WP_Roles::add_role() WP 5.5.3

<?php
public function add_role( $role, $display_name, $capabilities = array() ) {
	if ( empty( $role ) || isset( $this->roles[ $role ] ) ) {
		return;
	}

	$this->roles[ $role ] = array(
		'name'         => $display_name,
		'capabilities' => $capabilities,
	);
	if ( $this->use_db ) {
		update_option( $this->role_key, $this->roles );
	}
	$this->role_objects[ $role ] = new WP_Role( $role, $capabilities );
	$this->role_names[ $role ]   = $display_name;
	return $this->role_objects[ $role ];
}