Skip to main content

How to reset WordPress user roles and capabilities?

Learn to reset WordPress roles and capabilities with WP-CLI to fix issues with missing or damaged settings.

Updated yesterday

If your WordPress roles or user capabilities got deleted or damaged, you can restore the WordPress user roles and capabilities using WP-CLI.

Step 1 - Connect via SSH

Connect to your account via SSH and open the directory where you installed WordPress. For most domains, it will be the public_html folder, so to reach the path, use the following command:

cd ~/domains/domain.tld/public_html

Make sure to replace domain.tld with your domain name.

Step 2 - Check existing user roles & capabilities

Checking roles

Before making any changes, we should first check the existing roles to see if any of them need to be reset. For that, we can use this command:

wp role list

WordPress has five pre-defined roles: Administrator, Editor, Author, Contributor, and Subscriber. One additional Super Admin role is available on WordPress multisite networks.

Your website's plugins may create additional roles. For example, WooCommerce users may find additional "Customer" and "Shop Manager" roles available on their website.

Checking capabilities

If all default user roles exist, we should verify whether their capabilities are properly assigned. To do that, we can use this command:

wp cap list administrator

To check other roles, simply replace administrator with the name of the role you want to check.

If the output appears empty or is missing essential capabilities, your user roles may be damaged. See WordPress Roles and Capabilities documentation for a complete list of default capabilities per role.

Step 3 - Resetting roles & capabilities to default settings

If any of the default roles or their capabilities are missing, we can use WP-CLI to reset them. To reset the administrator role and its capabilities, we can use this command:

wp role reset administrator

To reset other roles (or their capabilities), simply replace administrator with the name of the role you want to reset.

Alternatively, we can reset all roles and their capabilities with a single command:

wp role reset --all

Warning: Using wp role reset --all will reset all roles on your site, including custom roles created by plugins. This will remove custom capabilities and restore the roles to their default state. Please be sure to proceed with caution and make sure you have a backup.

After resetting, confirm all needed roles exist using wp role list. Then, check if the roles have restored capabilities correctly by re-running wp cap list administrator.

Did this answer your question?