2017 © Pedro PelĂĄez
 

wp-cli-package role-command

Adds, removes, lists, and resets roles and capabilities.

image

wp-cli/role-command

Adds, removes, lists, and resets roles and capabilities.

  • Friday, April 20, 2018
  • by danielbachhuber
  • Repository
  • 3 Watchers
  • 5 Stars
  • 256,821 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 9 Forks
  • 0 Open issues
  • 11 Versions
  • 22 % Grown

The README.md

wp-cli/role-command

Adds, removes, lists, and resets roles and capabilities., (*1)

Testing, (*2)

Quick links: Using | Installing | Contributing | Support, (*3)

Using

This package implements the following commands:, (*4)

wp role

Manages user roles, including creating new roles and resetting to defaults., (*5)

wp role

See references for Roles and Capabilities and WP User class., (*6)

EXAMPLES, (*7)

# List roles.
$ wp role list --fields=role --format=csv
role
administrator
editor
author
contributor
subscriber

# Check to see if a role exists.
$ wp role exists editor
Success: Role with ID 'editor' exists.

# Create a new role.
$ wp role create approver Approver
Success: Role with key 'approver' created.

# Delete an existing role.
$ wp role delete approver
Success: Role with key 'approver' deleted.

# Reset existing roles to their default capabilities.
$ wp role reset administrator author contributor
Success: Reset 3/3 roles.

wp role create

Creates a new role., (*8)

wp role create <role-key> <role-name> [--clone=<role>]

OPTIONS, (*9)

<role-key>
    The internal name of the role.

<role-name>
    The publicly visible name of the role.

[--clone=<role>]
    Clone capabilities from an existing role.

EXAMPLES, (*10)

# Create role for Approver.
$ wp role create approver Approver
Success: Role with key 'approver' created.

# Create role for Product Administrator.
$ wp role create productadmin "Product Administrator"
Success: Role with key 'productadmin' created.

wp role delete

Deletes an existing role., (*11)

wp role delete <role-key>

OPTIONS, (*12)

<role-key>
    The internal name of the role.

EXAMPLES, (*13)

# Delete approver role.
$ wp role delete approver
Success: Role with key 'approver' deleted.

# Delete productadmin role.
wp role delete productadmin
Success: Role with key 'productadmin' deleted.

wp role exists

Checks if a role exists., (*14)

wp role exists <role-key>

Exits with return code 0 if the role exists, 1 if it does not., (*15)

OPTIONS, (*16)

<role-key>
    The internal name of the role.

EXAMPLES, (*17)

# Check if a role exists.
$ wp role exists editor
Success: Role with ID 'editor' exists.

wp role list

Lists all roles., (*18)

wp role list [--fields=<fields>] [--field=<field>] [--format=<format>]

OPTIONS, (*19)

[--fields=<fields>]
    Limit the output to specific object fields.

[--field=<field>]
    Prints the value of a single field.

[--format=<format>]
    Render output in a particular format.
    ---
    default: table
    options:
      - table
      - csv
      - json
      - count
      - yaml
    ---

AVAILABLE FIELDS, (*20)

These fields will be displayed by default for each role:, (*21)

  • name
  • role

There are no optional fields., (*22)

EXAMPLES, (*23)

# List roles.
$ wp role list --fields=role --format=csv
role
administrator
editor
author
contributor
subscriber

wp role reset

Resets any default role to default capabilities., (*24)

wp role reset [<role-key>...] [--all]

Uses WordPress' populate_roles() function to put one or more roles back into the state they were at in the a fresh WordPress install. Removes any capabilities that were added, and restores any capabilities that were removed. Custom roles are not affected., (*25)

OPTIONS, (*26)

[<role-key>...]
    The internal name of one or more roles to reset.

[--all]
    If set, all default roles will be reset.

EXAMPLES, (*27)

# Reset three roles.
$ wp role reset administrator author contributor
Restored 1 capability to and removed 0 capabilities from 'administrator' role.
No changes necessary for 'author' role.
No changes necessary for 'contributor' role.
Success: 1 of 3 roles reset.

# Reset a custom role.
$ wp role reset custom_role
Custom role 'custom_role' not affected.
Error: Must specify a default role to reset.

# Reset all default roles.
$ wp role reset --all
Success: All default roles reset.

wp cap

Adds, removes, and lists capabilities of a user role., (*28)

wp cap

See references for Roles and Capabilities and WP User class., (*29)

EXAMPLES, (*30)

# Add 'spectate' capability to 'author' role.
$ wp cap add 'author' 'spectate'
Success: Added 1 capability to 'author' role.

# Add all caps from 'editor' role to 'author' role.
$ wp cap list 'editor' | xargs wp cap add 'author'
Success: Added 24 capabilities to 'author' role.

# Remove all caps from 'editor' role that also appear in 'author' role.
$ wp cap list 'author' | xargs wp cap remove 'editor'
Success: Removed 34 capabilities from 'editor' role.

wp cap add

Adds capabilities to a given role., (*31)

wp cap add <role> <cap>... [--grant]

OPTIONS, (*32)

<role>
    Key for the role.

<cap>...
    One or more capabilities to add.

[--grant]
    Adds the capability as an explicit boolean value, instead of implicitly defaulting to `true`.
    ---
    default: true
    options:
      - true
      - false
    ---

EXAMPLES, (*33)

# Add 'spectate' capability to 'author' role.
$ wp cap add author spectate
Success: Added 1 capability to 'author' role.

wp cap list

Lists capabilities for a given role., (*34)

wp cap list <role> [--format=<format>] [--show-grant]

OPTIONS, (*35)

<role>
    Key for the role.

[--format=<format>]
    Render output in a particular format.
    ---
    default: list
    options:
      - list
      - table
      - csv
      - json
      - count
      - yaml
    ---

[--show-grant]
    Display all capabilities defined for a role including grant.
    ---
    default: false
    ---

EXAMPLES, (*36)

# Display alphabetical list of Contributor capabilities.
$ wp cap list 'contributor' | sort
delete_posts
edit_posts
level_0
level_1
read

wp cap remove

Removes capabilities from a given role., (*37)

wp cap remove <role> <cap>...

OPTIONS, (*38)

<role>
    Key for the role.

<cap>...
    One or more capabilities to remove.

EXAMPLES, (*39)

# Remove 'spectate' capability from 'author' role.
$ wp cap remove author spectate
Success: Removed 1 capability from 'author' role.

Installing

This package is included with WP-CLI itself, no additional installation necessary., (*40)

To install the latest version of this package over what's included in WP-CLI, run:, (*41)

wp package install git@github.com:wp-cli/role-command.git

Contributing

We appreciate you taking the initiative to contribute to this project., (*42)

Contributing isn’t limited to just code. We encourage you to contribute in the way that best fits your abilities, by writing tutorials, giving a demo at your local meetup, helping other users with their support questions, or revising our documentation., (*43)

For a more thorough introduction, check out WP-CLI's guide to contributing. This package follows those policy and guidelines., (*44)

Reporting a bug

Think you’ve found a bug? We’d love for you to help us get it fixed., (*45)

Before you create a new issue, you should search existing issues to see if there’s an existing resolution to it, or if it’s already been fixed in a newer version., (*46)

Once you’ve done a bit of searching and discovered there isn’t an open or fixed issue for your bug, please create a new issue. Include as much detail as you can, and clear steps to reproduce if possible. For more guidance, review our bug report documentation., (*47)

Creating a pull request

Want to contribute a new feature? Please first open a new issue to discuss whether the feature is a good fit for the project., (*48)

Once you've decided to commit the time to seeing your pull request through, please follow our guidelines for creating a pull request to make sure it's a pleasant experience. See "Setting up" for details specific to working on this package locally., (*49)

Support

GitHub issues aren't for general support questions, but there are other venues you can try: https://wp-cli.org/#support, (*50)

This README.md is generated dynamically from the project's codebase using wp scaffold package-readme (doc). To suggest changes, please submit a pull request against the corresponding part of the codebase., (*51)

The Versions

20/04 2018

dev-master

9999999-dev https://github.com/wp-cli/role-command

Adds, removes, lists, and resets roles and capabilities.

  Sources   Download

MIT

The Development Requires

20/04 2018

v1.1.0

1.1.0.0 https://github.com/wp-cli/role-command

Adds, removes, lists, and resets roles and capabilities.

  Sources   Download

MIT

The Development Requires

20/04 2018

dev-refresh-scaffold-files

dev-refresh-scaffold-files https://github.com/wp-cli/role-command

Adds, removes, lists, and resets roles and capabilities.

  Sources   Download

MIT

The Development Requires

19/04 2018

dev-fix-travis-53-memory

dev-fix-travis-53-memory https://github.com/wp-cli/role-command

Adds, removes, lists, and resets roles and capabilities.

  Sources   Download

MIT

The Development Requires

23/02 2018

dev-16-list-field

dev-16-list-field https://github.com/wp-cli/role-command

Adds, removes, lists, and resets roles and capabilities.

  Sources   Download

MIT

The Development Requires

08/12 2017

v1.0.5

1.0.5.0 https://github.com/wp-cli/role-command

Adds, removes, lists, and resets roles and capabilities.

  Sources   Download

MIT

The Development Requires

21/11 2017

v1.0.4

1.0.4.0 https://github.com/wp-cli/role-command

Manage user roles and capabilities.

  Sources   Download

MIT

The Development Requires

29/09 2017

v1.0.3

1.0.3.0 https://github.com/wp-cli/role-command

Manage user roles and capabilities.

  Sources   Download

MIT

The Development Requires

04/08 2017

v1.0.2

1.0.2.0 https://github.com/wp-cli/role-command

Manage user roles and capabilities.

  Sources   Download

MIT

The Development Requires

30/05 2017

v1.0.1

1.0.1.0 https://github.com/wp-cli/role-command

Manage user roles and capabilities.

  Sources   Download

MIT

The Development Requires

17/04 2017

v1.0.0

1.0.0.0 https://github.com/wp-cli/role-command

Manage user roles and capabilities.

  Sources   Download

MIT

The Development Requires