WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Okay so I'm building out a plugin that generates a list from the $menu and possibly $submenu. I want to loop through that array and generate that list by the menu_slug, but I cannot seem to figure out how to do that.

Essentially what my plugin does is it will have the menu title with a checkbox next to it. Upon checking that box and hitting submit it will remove that menu item from the admin menu on the left.

Now I know I can set it to if a certain user can edit menus then do a certain function. Which is great but the removing part is where I am stuck.

remove_menu_page( 'link-manager.php' );

Is what i've been looking at but this only removes that specific menu item. I'm thinking it would be some sort of loop that goes through the menu and is kinda like

if ( !current_user_can( 'manage_options' )) {
  loop through menu and generate the menu title with the input checkbox
share|improve this question
What about add_action( 'admin_notices', 'wpse_112968' ); function wpse_112968() { global $menu, $submenu; var_dump($menu, $submenu); } – brasofilo Sep 7 '13 at 3:54
I'll see about checking that out. Since asking i've kinda figured out my problem with a bit of help, but i'll definitely look into that. – Tyler Gerig Sep 7 '13 at 7:39

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.