2

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

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
));
  • 1
    That's correct (and what I was aiming for), but for the capabilities that I don't specify in the array - do they default to true or false? – MarketHubb Sep 3 '15 at 18:23
  • @MarketHubb the other capabilities are false by default (for read capability). read this for roles and capabilities. – girardengo Sep 3 '15 at 23:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.