update_role


update_role ( $role, $display_name = null, $capabilities = null )

Parameters:
  • (string) role Role name.
  • (string|null) display_name Optional. Role display name. If null, the display name is not modified. 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.
Returns:
  • (WP_Role|void) WP_Role object, if the role is updated.
Defined at:

Description

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.

Related Functions

update_core, update_meta, wp_update_core, populate_roles, update_archived

Top Google Results

User discussions

wpseek mobile