• Skip to primary navigation
  • Skip to main content
OsomCode

OsomCode

Awesome code tutorials for WordPress and Genesis

  • Subscribe
  • My account
    • Edit profile
    • Favorites
    • Update credit card
  • Login

Remove a WordPress user role

Discover in this code tutorial how to remove a user role in WordPress with a simple snippet.

By default, WordPress has 5 user roles:

  • Subscriber
  • Contributor
  • Author
  • Publisher
  • Administrator

In addition to these, some Plugins can add new roles. For example, WooCommerce creates two more:

  • Customer
  • 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:

To see this and another 883 code snippets of this website, login or subscribe here.

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. 😉

Conclusion

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. 😉

Admin area PHP WordPress

To leave read and make questions about this code, you can login or register.

  • About OsomCode
  • FAQ
  • Contact

Legal Notice · Privacy Policy · Cookie Policy · Terms and conditions
Copyright © 2023

Lost your password?