How to reset WordPress user roles and capabilities

Reset WordPress user roles and capabilities at Hostinger with WP-CLI to restore deleted or damaged roles, one at a time or all at once.

Updated 3 weeks ago

Reset WordPress user roles and capabilities at Hostinger with WP-CLI to restore deleted or damaged roles, such as Administrator or Editor. Connect via SSH, check the existing roles and capabilities, then reset one role or all roles to their defaults.

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
Hostinger terminal showing wp role list output with WordPress roles and capabilities

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.

Hostinger terminal showing wp cap list administrator with WordPress administrator capabilities

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.

Hostinger terminal showing wp role reset administrator success message

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

wp role reset --all

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.

Once your roles are restored, users regain the WordPress Admin area options their role allows. If you still can’t access the WordPress Admin area, see Troubleshooting issues accessing WordPress admin login page at Hostinger.