Menu capability in WordPress

Is it possible to specify two usergroups (e.g. admins and editors) into the admin menu capability field ? I tried the following but it doesnt work:

add_submenu_page(
     'my-top-level-handle',
     'Page title',
     'Sub-menu title',
      array('administrator', 'editor'),
     'my-submenu-handle',
     'my_magic_function'
);

error message:

Read More

Warning: Illegal offset type in isset or empty in C:wampwwwwordpresswp-includescapabilities.php on line 712

Related posts

Leave a Reply

2 comments

  1. Capability parameter of add_submenu_page() function can only take a single capability,
    so if you are using the built in roles you can select a capability fro the long list that both administrators and editors have any of these
    (use any of these freely):

    • moderate_comments
    • manage_categories
    • manage_links
    • unfiltered_html
    • edit_others_posts
    • edit_pages
    • edit_others_pages
    • edit_published_pages
    • publish_pages
    • delete_pages
    • delete_others_pages
    • delete_published_pages
    • delete_others_posts
    • delete_private_posts
    • edit_private_posts
    • read_private_posts
    • delete_private_pages
    • edit_private_pages
    • read_private_pages
  2. As t31os said, you can use capabilities instead of roles there. One way to do this is to use core capabilities. (A more advanced method is to add a custom capability to the roles of your choice.) The default caps are in wp-admin/includes/schema.php in the functions called by populate_roles().

    If you are using standard roles/caps, you can specify only admins and editors by the cap level_7 or edit_others_posts or several others.