Discover in this code tutorial how to restore the default WordPress user roles with a simple snippet.
By default, WordPress has 5 user roles:
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:
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.
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. 🙂