roles
In WordPress, you can create a new role with subscriber capabilities by using the add_role() function in your theme's functions.php file or a custom plugin.
In WordPress, you can create a new role with subscriber capabilities by using the add_role() function in your theme’s functions.php file or a custom plugin. Here’s an example of how you can do it:
add_role(
'subscriber_plus',
__( 'Subscriber Plus' ),
array(
'read' => true,
'edit_posts' => false,
'delete_posts' => false,
)
);
In this example, the add_role()
function creates a new role called “Subscriber Plus”. The third argument is an array of capabilities, where the keys are the capability names and the values are booleans indicating whether the role has that capability or not. In this case, the role has the read
capability set to true
and the edit_posts
and delete_posts
capabilities set to false
.
After adding this code to your functions.php file or plugin, you will be able to assign the new “Subscriber Plus” role to users in the WordPress dashboard under Users > All Users.