Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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

share|improve this question
1  
You're not suppose to pass a role(or roles) to the capability parameter. Give it a capability only editors(or above) have and the page will be available to both admins and editors. –  t31os Mar 30 '11 at 15:57
    
@t31os Please stop posting your answers into comments or I cannot give you the rep that you deserve. :) –  toscho Mar 30 '11 at 22:12
    
@toscho - Sometimes i just intend to comment and answer without even realising, i'm just too impatient to think before i click that button... sorry.. :) –  t31os Mar 30 '11 at 22:28
add comment

2 Answers

up vote 3 down vote accepted

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 og these:

  • 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
share|improve this answer
add comment

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.

share|improve this answer
    
level is deprecated for years. It may be dropped in the near future. –  toscho Mar 30 '11 at 22:14
add comment

Your Answer

 
discard

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.