WordPress.org

Support

Support » Plugins and Hacks » Hacks » How to hide one menu item from Admin (appearance – menus)

How to hide one menu item from Admin (appearance – menus)

  • Hey guys,

    Does anyone knows how to hide a specific menu from the Appearance -> Menus?

    I have few different menu tabs and I want to hide one menu tab so the menu won’t be modified. nav-menus.php?action=edit&menu=3

    Is there any way to do that?

    I was trying to use Adminimize but it can’t hide a specific navigation tab from there.

Viewing 2 replies - 1 through 2 (of 2 total)
  • I was thinking it should be something in those lines:

    add_filter( 'wp_get_nav_menu_items', array( 'exclude_menu_items' )3 );

    What do you guys think?

    I use this to remove the portfolio menu item from “editors” just change “editor” to “admin” and then update the menu item you want to restrict. Put this in functions.php

    function custom_remove_menus(){
    
        // Get current user's data
        $current_user = wp_get_current_user();
        $user_id = $current_user->ID;
    
        // Check user's roles
        $user = new WP_User( $user_id );
        if ( !empty( $user->roles ) && is_array( $user->roles ) ) {
            if( in_array( 'editor', $user->roles ) ) {
                // Remove menu items
                remove_menu_page( 'edit.php?post_type=portfolio');
            }
        }
    }
    
    add_action( 'admin_menu', 'custom_remove_menus' );

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘How to hide one menu item from Admin (appearance – menus)’ is closed to new replies.
Skip to toolbar