Skip to content

Instantly share code, notes, and snippets.

@mspalex
Last active August 19, 2016 15:15
Show Gist options
  • Save mspalex/bcfb82bfc02d6009c76b to your computer and use it in GitHub Desktop.
Save mspalex/bcfb82bfc02d6009c76b to your computer and use it in GitHub Desktop.
Wordpress - Remove Admin menus - items from wordpress and plugins
<?php
/* Remove admin menus, to prevent access to certain areas like
page editing, plugins and templates
*/
add_action( 'admin_menu', 'remove_menus' );
function remove_menus(){
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 admin menu items by slug - PLUGIN MENU ITEMS
*/
add_action( 'admin_init', 'remove_menus_after' );
function remove_menus_after(){
remove_menu_page( 'WpFastestCacheOptions' );
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment