WordPress includes several user roles with sensible permissions that cater to most sites, but what if you need to modify a role to add or remove capabilities? You can easily modify a role's permissions using WP-CLI.
For a list of all WordPress roles and capabilities, see the Roles and Capabilities page within the WordPress documentation.
Listing Capabilities for a User Role
From your WordPress site's root directory, run the following command to list all capabilities that a user role has, replacing role_name with the name of the role.
pagely-wp cap list role_name
Removing a Capability from a User Role
To remove a capability from a user role, you can use the following command when in your WordPress site's root directory, replacing role_name and capability_name with the name of the role and capability that you want to remove:
pagely-wp cap remove role_name capability_name
Adding a Capability to a User Role
If you want to add an additional capability to a user role, you can use the following WP-CLI command from within your site's root directory. Don't forget to change role_name and role_capability to the role and capability that you want to add!
pagely-wp cap add role_name capability_name