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.

My theme currently uses add_menu_page() in order to display the theme options sections on the left hand admin menu.

I would like to be able to attach a parent css class to the main menu item in order to selectively show/hide the menus for advanced users.

I don't see this documented in the codex so I'm asking here to find out if there is a workaround or undocumented feature that I can utilize.

Any help, much appreciated.

The basic idea is that I have one main menu item and about 8 submenu items. Currently, all the menu items are displayed in the menu. I would like to use custom css to toggle the visibility of the submenu items, however, there is currently no custom id or class that I can use to target my menus.

share|improve this question
    
I don't get where exactly you want the classes. Can you post the base of your code? And detail the submenu behavior? –  brasofilo Mar 26 '13 at 15:17

1 Answer 1

up vote 0 down vote accepted

You should not do this via CSS as the underlying functionality would still be there (and thus open for direct access).

I'd rather rewrite the theme in a way that the menu pages are only added if the current user has a certain capability.

if (current_user_can( SOME_CAP )) {
    add menu pages ...
}

You could even provide a new capability for your theme. Have a look over here, if you're interested in this.

share|improve this answer

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.