I've added a separate menu page (an object page) with minimum access level required as 'Subscriber'. I'm doing this because I'm registering new users and they'll be 'Subscribers' with an extra capability to edit a section that my plugin creates. So I want them to be able to see this menu as well. I created my menu page as follows:

add_object_page('Personal Section', 'Personal Section', 'subscriber', 'personal-section', 'personal_section_fn');

Now when I log in with the subscriber credentials, I'm able to see this menu, but I'm not able to see it when logged in as Admin. Am I doing something wrong here?

Thanks in advance!

  • Any reason you're using add_object_page(), rather than add_settings_page(), or - if you must - add_menu_page()? – Chip Bennett Apr 25 '11 at 19:05

subscriber is a role, not a capability. Use a capability to manage access, e.g. read.

To understand the difference better install Justin Tadlock’s plugin Members.
For the subscriber role you get a list of capabilities like this:

enter image description here

The administrator role in contrast:

enter image description here

  • @Chip I'm using 'add_object_page' because I want my menu to appear along with the other menus, it the same list as Posts, Comments etc. because my custom post shows up there and this menu works with those custom posts. 'add_menu_page' adds it as a separate menu item. @toscho I'm adding a new custom capability to the Subscriber role, I will use this capability to allow the user to see this custom menu page I'm creating (if <cap> show else don't show). But for that I need to create this menu with a minimum access level as subscriber so that subscribers are always allowed to see this menu. – Rutwick Gangurde Apr 26 '11 at 9:53
  • @Rutwick Gangurde Roles are not access levels. Such a thing does not exist in WordPress. Don’t see these roles as hierarchies, they are just names for predefined sets of capabilities. – fuxia Apr 26 '11 at 10:18
  • @toscho Ok... my bad! Say, I create a new custom role 'tester', with read capability and a custom capability, 'test'. I just want the users under this role to see the menu page I'm creating above when they log in! So what minimum capability do I mention when adding the menu page? I said subscribers above because subscriber role has only 'Read' capability, and so does my new role with a custom capability. I hope now I'm clear with my question! – Rutwick Gangurde Apr 26 '11 at 17:19
  • @Rutwick Gangurde You have to assign the capability to all roles that should be able to see the menu. But read should do it. All roles have this capability. – fuxia Apr 26 '11 at 17:24
  • @toscho Thanks a lot! I assigned the custom capability 'test' for creating the menu page and I assigned it to 'administrator' role also, and bingo, it worked! Now both my custom role and admin can see that menu page! Thanks all for your help! – Rutwick Gangurde Apr 28 '11 at 6:39

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.