Discover in this tutorial how to give the ability to view Restrict Content Pro memberships to a custom WordPress user role via code, without plugins.
By default, WordPress has 5 user roles:
- Subscriber >
( 'subscriber' )
- Contributor > (
- Author > (
- Editor >
( 'editor' )
- Administrator >
( 'administrator' )
In addition to these, some plugins can add new roles. For example, WooCommerce creates two more:
- Store manager
In this case, I’m going to tell you how you can extend the capabilities of the user role of your choice so that it can access Restrict Content Pro memberships. Something very practical, for example, if you want to give it access to a virtual assistant.
Let’s see how to do it:
Snippet to allow a user role to have access to Restrict Content Pro memberships
Add the following code at the end of functions.php or in your functionality plugin:
With this snippet you first get the
'assistant' role and then add the ability to view memberships with the
This is just an example, where you allow the person(s) who have the
wizard role to have access to review Restrict Content Pro memberships. But the idea is that you assign it to the user role that interests you.
You can also play with the different capabilities of the plugin, which are as follows:
Ass you see, you can apply them quite granularly.
By the way, the new capability is saved in the database so once you have refreshed the page, which will cause the code to execute, you can delete the snippet.
Now you know how to allow a WordPress user role to view Restrict Content Pro memberships, with a simple snippet of code.
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. 🙂