Discover in this code tutorial how to restore the default WordPress user roles with a simple snippet.
By default, WordPress has 5 user roles:
- Subscriber
- Contributor
- Author
- Publisher
- Administrator
But what if you have deleted some of those WordPress roles using this code and now you want to recover them?
No problem, because the CMS has the populate_roles() function that allows you to restore the default WordPress roles.
You can use it like this:
Snippet to restore WordPress user roles
Add the following code at the end of functions.php or in your functionality plugin:
To see this and another 1097 code snippets of this website, login or subscribe here.
There you have it, with this snippet you get back the default WordPress user roles.
In addition, if you want you can also create new custom user roles.
Conclusion
Now you know how to restore default WordPress user roles without plugins, using a simple code snippet.
If you have any question, please leave it in the comments. And if you want to give me a suggestion for future snippets, please send it through the contact form.
Benefits of being a subscriber. 🙂