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:

Warning: Illegal offset type in isset or empty in C:\wamp\www\wordpress\wp-includes\capabilities.php on line 712

2 Answers
2

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

Leave a Comment