Skip to content
This repository was archived by the owner on Feb 24, 2025. It is now read-only.

Overrides remove_menu_page #37

@blogmom

Description

@blogmom

With 2.0.0.-alpha: In my functions.php, I check if a user is an admin, and if not, then I hide all Admin Panel items using remove_menu_page. However, when AMM is activated, certain items reappear: Home, All Posts, All Comments, Available Tools. This is consistent and repeatable. When AMM plugin is deactivated, the items are again hidden. Here is my code, pop it into your functions.php and you'll see what I mean. With that code in your functions.php:

  1. deactivate AMM plugin and login as a non-admin user, navigate to wp-admin and notice the panel is empty.
  2. activate AMM plugin and refresh, notice the admin panel is no longer empty.
add_action('admin_menu', 'remove_admin_sidebar_from_endusers'); 
function remove_admin_sidebar_from_endusers ()  { 
    get_currentuserinfo();
    global $user_level;
    if ( $user_level <= 8 ) {
        remove_menu_page( 'index.php' );                  //Dashboard
        remove_menu_page( 'profile.php' );                //Profile     
        remove_menu_page( 'jetpack' );                    //Jetpack* 
        remove_menu_page( 'edit.php' );                   //Posts
        remove_menu_page( 'upload.php' );                 //Media
        remove_menu_page( 'edit.php?post_type=page' );    //Pages
        remove_menu_page( 'edit-comments.php' );          //Comments
        remove_menu_page( 'themes.php' );                 //Appearance
        remove_menu_page( 'plugins.php' );                //Plugins
        remove_menu_page( 'users.php' );                  //Users
        remove_menu_page( 'tools.php' );                  //Tools
        remove_menu_page( 'options-general.php' );        //Settings
        //echo "<script type='text/javascript' >document.body.className+=' folded';</script>";  //collapse by default
        remove_meta_box('dashboard_right_now', 'dashboard', 'core');
        remove_meta_box('dashboard_activity', 'dashboard', 'core');
        remove_meta_box('dashboard_recent_comments', 'dashboard', 'core');
        remove_meta_box('dashboard_incoming_links', 'dashboard', 'core');
        remove_meta_box('dashboard_plugins', 'dashboard', 'core');
        remove_meta_box('dashboard_quick_press', 'dashboard', 'core');
        remove_meta_box('dashboard_recent_drafts', 'dashboard', 'core');
        remove_meta_box('dashboard_primary', 'dashboard', 'core');
        remove_meta_box('dashboard_secondary', 'dashboard', 'core');        
    } 
} 

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions