Skip to content

Instantly share code, notes, and snippets.

@jpmarchand
Last active October 21, 2019 18:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save jpmarchand/4ec464ac8536dccff8c52c8669c432a6 to your computer and use it in GitHub Desktop.
Save jpmarchand/4ec464ac8536dccff8c52c8669c432a6 to your computer and use it in GitHub Desktop.
Remove specific admin menu items from users in WordPress. Source: https://generatewp.com/hooks/?clone=wnd6xyb
<?php
//* Remove admin menu items from users in WordPress
add_action( 'admin_menu', 'customprefix_remove_admin_menus', 10, 1 );
function customprefix_remove_admin_menus( $context ) {
// Hide from users with low privilege
if ( ! current_user_can( 'manage_options' ) ) {
// Core Menus
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
// Plugins
remove_menu_page( 'jetpack' ); // Jetpack
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment