/**************************************************
* 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
Plugin | Slug |
All Export | pmxi-admin-home |
All Import | pmxe-admin-home |
Bookly | bookly-menu |
Bookly Cloud | bookly-cloud-menu |
Digits | digits_settings |
Duplicator | duplicator |
WooCommerce | woocommerce |
WooCommerce Marketing | woocommerce-marketing |
Creative Mail by Constant Contact | creative email |
Feedback | feedback |
GenerateBlocks | generateblocks |
Loco Translate | loco |
Toolset | toolset-dashboard |
WooCommerce Analytics | wc-admin&path=/analytics/overview |
WooCommerce Products | edit.php?post_type=product |
WP Mail SMTP | wp-mail-smtp |
WP Security | aiowpsec |
WP Staging | wpstg_clone |
Avada | avada | avada-white-label-branding-admin |
WP Mail Logging | wpml_plugin_log |
WP Mail SMTP | wp-mail-smtp |
LiteSpeed Cache | litespeed |