WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.


$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.';
share|improve this question
up vote 3 down vote accepted

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,
share|improve this answer
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 posting your answer, you agree to the privacy policy and terms of service.

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