Examples
# List all registered abilities.
$ wp ability list
+---------------------------+----------------------+----------+------------------------------------------+
| name | label | category | description |
+---------------------------+----------------------+----------+------------------------------------------+
| core/get-site-info | Get Site Information | site | Returns site information configured i... |
| core/get-user-info | Get User Information | user | Returns basic profile details for the... |
| core/get-environment-info | Get Environment Info | site | Returns core details about the site's... |
+---------------------------+----------------------+----------+------------------------------------------+
# Get details of a specific ability.
$ wp ability get core/get-site-info --fields=name,label,category,readonly,show_in_rest
+---------------+----------------------+
| Field | Value |
+---------------+----------------------+
| name | core/get-site-info |
| label | Get Site Information |
| category | site |
| readonly | 1 |
| show_in_rest | 1 |
+---------------+----------------------+
# Execute an ability with JSON input (required for array values).
$ wp ability run core/get-site-info --input='{"fields":["name","version"]}' --user=admin
{
"name": "Test Blog",
"version": "6.9"
}
# Check if an ability exists.
$ wp ability exists core/get-site-info
$ echo $?
0
# Check if user can run an ability.
$ wp ability can-run core/get-site-info
$ echo $?
0
# Validate input before execution.
$ wp ability validate core/get-site-info --input='{"fields":["name","version"]}'
Success: Input is valid.
Subcommands
| Name | Description |
|---|---|
| wp ability can-run | Checks if the current user can execute an ability. |
| wp ability category | Lists and inspects ability categories registered via the WordPress Abilities API. |
| wp ability exists | Checks whether an ability is registered. |
| wp ability get | Gets details about a registered ability. |
| wp ability list | Lists all registered abilities. |
| wp ability run | Executes a registered ability. |
| wp ability validate | Validates input against an ability’s schema. |