Remove unwanted menu/submenu links from wordpress dashboard

Remove menu page links:

function remove_menus()
{
global $submenu;

remove_menu_page( ‘link-manager.php’ ); // Links
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(‘edit.php?post_type=acf’); // Settings
}

add_action(‘admin_menu’, ‘remove_menus’);

 

Remove sub menu page links:

add_action(‘admin_menu’, ‘remove_menus’);
function remove_menus()
{
global $submenu;

remove_submenu_page ( ‘index.php’, ‘update-core.php’ );    //Dashboard->Updates
}

 

You can also remove page links according users based on roles, given blow code will remove the links if user is editor.

add_action(‘admin_menu’, ‘remove_menus’);
function remove_menus()
{
if(currene_user_can(‘editor’)){
remove_menu_page( ‘link-manager.php’ ); // Links
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(‘edit.php?post_type=acf’);

remove_submenu_page ( ‘index.php’, ‘update-core.php’ );    //Dashboard->Updates

}
}

Share This Post

Post Comment