wp cap
Adds, removes, and lists capabilities of a user role.
See references for Roles and Capabilities and WP User class.
Subcommands
| Command | Description |
|---|---|
wp cap add |
Adds capabilities to a given role. |
wp cap list |
Lists capabilities for a given role. |
wp cap remove |
Removes capabilities from a given role. |
Examples
# 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.
Synopsis
wp cap add <role> <cap>... [--grant]
Parameters
| Parameter | Description |
|---|---|
<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
$ wp cap add author spectate
Success: Added 1 capability to 'author' role.
wp cap list
Lists capabilities for a given role.
Synopsis
wp cap list <role> [--format=<format>] [--show-grant]
Parameters
| Parameter | Description |
|---|---|
<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
# 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.
Synopsis
wp cap remove <role> <cap>...
Parameters
| Parameter | Description |
|---|---|
<role> |
Key for the role. |
<cap>... |
One or more capabilities to remove. |
Examples
$ wp cap remove author spectate
Success: Removed 1 capability from 'author' role.