Remove WordPress Admin menu

By

/**************************************************
 * Removes admin menu for specific users
**************************************************/
function ebz_remove_menus(){

	$users = array(1);   // Put user id here
	if ( current_user_can( 'manage_options' ) && ( !in_array(get_current_user_id(), $users, true) ) ) {
           
        remove_menu_page( 'index.php' );                // Dashboard
        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
        remove_menu_page( 'plugin-slug' );      // 3rd party plugins
	}
}
add_action( 'admin_init', 'ebz_remove_menus' );

List all available admin menu

function debug_admin_menu() {

    echo '<pre>' . print_r( $GLOBALS[ 'menu' ], TRUE) . '</pre>';
}
add_action( 'admin_init', 'debug_admin_menu' );

List of common plugins’ slug

PluginSlug
All Exportpmxi-admin-home
All Importpmxe-admin-home
Booklybookly-menu
Bookly Cloudbookly-cloud-menu
Digitsdigits_settings
Duplicatorduplicator
WooCommercewoocommerce
WooCommerce Marketingwoocommerce-marketing
Creative Mail by Constant Contactcreativemail
Feedbackfeedback
GenerateBlocksgenerateblocks
Loco Translateloco
Toolsettoolset-dashboard
WooCommerce Analyticswc-admin&path=/analytics/overview
WooCommerce Productsedit.php?post_type=product
WP Mail SMTPwp-mail-smtp
WP Securityaiowpsec

Leave a Comment