Assign Subscriber capabilities to a custom user role

I am creating a custom user role (client) for the application I am building, and I want this role to have extremely limited capabilities.

I am using the add_role( $role, $display_name, $capabilities ); to create the custom role.

$client_role = add_role('client', 'Client',
    array (
      'edit_posts' => false,
      'delete_posts' => false,
    ));

Here’s my question – instead of having to list each and every available capability, and setting it to ‘false’, is there a way to simply assign the capabilities that are available to a ‘Subscriber’ to my custom user role?

Would it be better to use a filter to just change the name of ‘Subscriber’ to ‘Client’?

Thanks!

1 Answer
1

WordPress subscriber have only the read capability. So you have to pass to add_role only the read parameter, like:

$client_role = add_role('client', 'Client',
array (
  'read' => TRUE // true allows this capability
));

Leave a Comment