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.

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!

share|improve this question
    
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

1 Answer 1

up vote 2 down vote accepted

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

share|improve this answer
    
@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. –  toscho 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. –  toscho 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

 
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.