Skip to content

Instantly share code, notes, and snippets.

@crewstyle
Created April 20, 2016 08:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save crewstyle/49a327e01bee6bce3592780dfb4b88e4 to your computer and use it in GitHub Desktop.
Save crewstyle/49a327e01bee6bce3592780dfb4b88e4 to your computer and use it in GitHub Desktop.
WordPress ~ Remove dashboard menus to editor role - #backend #security
<?php
/**
* Remove dashboard menus to editor role.
*
* @uses current_user_can() To know if current user has permissions.
* @uses remove_menu_page() To remove a menu page.
* @uses remove_submenu_page() To remove a submenu page.
* @see https://github.com/crewstyle/clean-wordpress
*/
add_action('admin_menu', '_cw_remove_menus_for_all');
function _cw_remove_menus_for_all()
{
//Remove WORDPRESS pages in the administration to all users, except the admin
if (!current_user_can('edit_users')) {
remove_submenu_page('themes.php', 'themes.php');
remove_menu_page('plugins.php');
remove_submenu_page('index.php', 'update-core.php');
remove_submenu_page('options-general.php', 'options-media.php');
remove_menu_page('link-manager.php');
remove_menu_page('tools.php');
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment