[ Index ]

PHP Cross Reference of WordPress

title

Body

[close]

/wp-includes/ -> class-wp-roles.php (summary)

User API: WP_Roles class

File Size: 372 lines (8 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 1 class

WP_Roles:: (15 methods):
  __construct()
  __call()
  _init()
  reinit()
  add_role()
  remove_role()
  add_cap()
  remove_cap()
  get_role()
  get_names()
  is_role()
  init_roles()
  for_site()
  get_site_id()
  get_roles_data()


Class: WP_Roles  - X-Ref

Core class used to implement a user roles API.

The role option is simple, the structure is organized by role name that store
the name in value of the 'name' key. The capabilities are stored as an array
in the value of the 'capability' key.

array (
'rolename' => array (
'name' => 'rolename',
'capabilities' => array()
)
)

__construct( $site_id = null )   X-Ref
Constructor

param: int $site_id Site ID to initialize roles for. Default is the current site.
since: 2.0.0
since: 4.9.0 The `$site_id` argument was added.

__call( $name, $arguments )   X-Ref
Make private/protected methods readable for backward compatibility.

return: mixed|false Return value of the callback, false otherwise.
param: string $name      Method to call.
param: array  $arguments Arguments to pass when calling.
since: 4.0.0

_init()   X-Ref
Set up the object properties.

The role key is set to the current prefix for the $wpdb object with
'user_roles' appended. If the $wp_user_roles global is set, then it will
be used and the role option will not be updated or used.

since: 2.1.0

reinit()   X-Ref
Reinitialize the object

Recreates the role objects. This is typically called only by switch_to_blog()
after switching wpdb to a new site ID.

since: 3.5.0

add_role( $role, $display_name, $capabilities = array()   X-Ref
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.

return: WP_Role|void WP_Role object, if role is added.
param: string $role         Role name.
param: string $display_name Role display name.
param: bool[] $capabilities List of capabilities keyed by the capability name,
since: 2.0.0

remove_role( $role )   X-Ref
Remove role by name.

param: string $role Role name.
since: 2.0.0

add_cap( $role, $cap, $grant = true )   X-Ref
Add capability to role.

param: string $role  Role name.
param: string $cap   Capability name.
param: bool   $grant Optional. Whether role is capable of performing capability.
since: 2.0.0

remove_cap( $role, $cap )   X-Ref
Remove capability from role.

param: string $role Role name.
param: string $cap  Capability name.
since: 2.0.0

get_role( $role )   X-Ref
Retrieve role object by name.

return: WP_Role|null WP_Role object if found, null if the role does not exist.
param: string $role Role name.
since: 2.0.0

get_names()   X-Ref
Retrieve list of role names.

return: string[] List of role names.
since: 2.0.0

is_role( $role )   X-Ref
Whether role name is currently in the list of available roles.

return: bool
param: string $role Role name to look up.
since: 2.0.0

init_roles()   X-Ref
Initializes all of the available roles.

since: 4.9.0

for_site( $site_id = null )   X-Ref
Sets the site to operate on. Defaults to the current site.

param: int $site_id Site ID to initialize roles for. Default is the current site.
since: 4.9.0

get_site_id()   X-Ref
Gets the ID of the site for which roles are currently initialized.

return: int Site ID.
since: 4.9.0

get_roles_data()   X-Ref
Gets the available roles data.

return: array Roles array.
since: 4.9.0



Generated: Thu Nov 21 01:00:03 2024 Cross-referenced by PHPXref 0.7.1