wpseek.com
A WordPress-centric search engine for devs and theme authors



update_role › WordPress Function

Since6.1.0
Deprecatedn/a
update_role ( $role, $display_name = null, $capabilities = null )
Parameters: (3)
  • (string) $role Role name.
    Required: Yes
  • (string|null) $display_name Optional. Role display name. If null, the display name is not modified. Default null.
    Required: No
    Default: null
  • (bool[]|null) $capabilities Optional. List of capabilities keyed by the capability name, e.g. `array( 'edit_posts' => true, 'delete_posts' => false )`. If null, don't alter capabilities for the existing role and make empty capabilities for the new one. Default null.
    Required: No
    Default: null
Returns:
  • (WP_Role|void) WP_Role object, if the role is updated.
Defined at:
Codex:

Updates an existing role. Creates a new role if it doesn't exist.

Modifies the display name and/or capabilities for an existing role. If the role does not exist then a new role is created. The capabilities are defined in the following format: array( 'read' => true ). To explicitly deny the role a capability, set the value for that capability to false.


Source

function update_role( $role, $display_name = null, $capabilities = null ) {
	return wp_roles()->update_role( $role, $display_name, $capabilities );
}