0

How do I remove a menu page that is added by a plugin like this:

add_action('admin_menu', array($this, 'add_menu'));

Where there is no slug. Looking at the plugin code and using the links in the anchors doesn't seem to work:

remove_menu_page( 'admin.php?page=tf_slider_list' );

Any suggestions how to remove these links from the menu? I'm going to be removing it for non-admins, so using it in conjunction with:

function custom_remove_menu_pages() {
    remove_menu_page( 'admin.php?page=tf_slider_list' );
}
add_action( 'admin_menu', 'custom_remove_menu_pages', 999 );

Update

I ended up displaying the global menu, and then using unset() to remove the $menu indexes. Any reason why I wouldn't do it this way:

function custom_remove_menu_pages() {

    global $menu;

    unset($menu[26]);
    unset($menu[27]);
    unset($menu[28]);
    unset($menu[29]);        
}
add_action( 'admin_menu', 'custom_remove_menu_pages', 999 );
2
  • Did you try using 'tf_slider_list' as the arg for remove_menu_page()? To clarify, you need to examine the 'add_menu' function in the plugin to get the slug, but I believe it should be 'tf_slider_list'. – skim- Dec 1 '14 at 22:59
  • Yep, you're right! Thanks, much cleaner than unset() – mtpultz Dec 2 '14 at 0:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.