Discover in this code tutorial how to remove a user role in WordPress with a simple snippet.
By default, WordPress has 5 user roles:
In addition to these, some Plugins can add new roles. For example, WooCommerce creates two more:
- Store Manager
Are you as fond of minimalism as OsomCode (and I ;)) and would you rather leave the installation of WordPress as clean as possible to your customers?
In that case you may find the following WordPress feature useful to delete some user roles.
Snippet to remove WordPress user roles
Add the following code at the end of functions.php or in your functionality plugin:
With the code block above you remove all user roles except for the administrator, but you can use only the lines you are interested in.
Warning: Proceed with caution before deleting a user role as this is a delicate process.
If there were any users with that role they would lose access to the website.
So be sure to make a copy of the database first.
If you prefer, in this tutorial you will learn how to create new user roles instead of deleting them. 😉
Now you know how to remove the WordPress user role you want without plugins, with a simple code snippet.
Any questions? Let me know in the comments.
And if you want to give me any suggestion for future tutorials, leave it in the contact form. Advantages of being a subscriber. 😉