[ Index ]

PHP Cross Reference of WordPress




/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):

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

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

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

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

_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.
since: 2.0.0
param: string $role         Role name.
param: string $display_name Role display name.
param: bool[] $capabilities List of capabilities keyed by the capability name,

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

since: 2.0.0
param: string $role Role name.

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

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

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

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

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.
since: 2.0.0
param: string $role Role name.

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
since: 2.0.0
param: string $role Role name to look up.

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.

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

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: Tue Jun 25 01:00:07 2024 Cross-referenced by PHPXref 0.7.1