• aggropixel

    (@aggropixel)


    So, I have managed to remove most menu items from the WP admin. However, I have a theme that uses a custom Options panel. This one I have tired like a million things including the following that is suppose to work.

    Screenshot: https://d.pr/i/B3ht
    Code I am using that doesn’t work for this one in functions.php.
    remove_menu_page('admin.php?page=goodlayers_admin_panel');

    Please help me, it is critical I get this removed so the client doesn’t change crap.

    Thanks,
    Josh

Viewing 2 replies - 1 through 2 (of 2 total)
  • You will need to remove the action that adds the menu page. Search the code and find add_action( 'admin_menu', 'function_name' ); //function_name will be the actual name of the function that adds the menu.

    Now add this code somewhere in your functions.php or a plugin.

    remove_action( 'admin_menu', 'function_name' ); //This should be written exactly as the function was added except we are using remove_action instead of add_action.

    scattered810

    (@scattered810)

    This example is to remove the “portfolio” menu item from the “editor” roles. Change the line with the portfolio info to yours (admin.php?page=goodlayers_admin_panel) and change editor to the admin user role. This snippet gets added to 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 ‘Remove stubborn admin menu page (gettin pissed))’ is closed to new replies.