2

On the WordPress codex Add Role page it says how to add a role, but I can not figure out how to do it, or that is inherits. Specially the comment //Use false to explicitly deny. What does that mean?

Does that mean if i do not say false to all the capability they can still do is if they guess the rigth URL?

Can somebody tell me the difference between true and false in wp role perspective, and how I should use it?

I am trying to make a user which can only edit pages. Nothing else.

http://codex.wordpress.org/Function_Reference/add_role

$result = add_role('basic_contributor', 'Basic Contributor', array(
    'read' => true, // True allows that capability
    'edit_posts' => true,
    'delete_posts' => false, // Use false to explicitly deny
));
if (null !== $result) {
    echo 'Yay!  New role created!';
} else {
    echo 'Oh... the basic_contributor role already exists.';
}
3

You must set to true for them to take affect. If you do not specify true they all default to NULL which in turn basically makes them false.

So to create a roll that allows pages only:

add_role('page_editor', 'Page Editor', array(
    'read' => true,
    'edit_others_pages' => true,
    'edit_pages' => true,
    'edit_published_pages' => true,
    'delete_pages' => true,
    'delete_published_pages' => true,
    'publish_pages' => true,
));
  • Thank you! So setting some of them to false like in the example from wordpress Codex is basiclly waste of time? – Kevin Simper Dec 28 '12 at 12:08

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.