Skip to content

Instantly share code, notes, and snippets.

@xditx32
Last active September 19, 2023 02:37
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 xditx32/a29941458486004a477a36bc9a3b1aca to your computer and use it in GitHub Desktop.
Save xditx32/a29941458486004a477a36bc9a3b1aca to your computer and use it in GitHub Desktop.
Hide WordPress menus in the admin area
/* Remove menus from the WordPress dashboard*/
function wpdocs_remove_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
remove_menu_page('edit.php?post_type=project'); //Projects
remove_menu_page('admin.php?page=flatsome-panel');
}
add_action('admin_menu', 'wpdocs_remove_menus');
/* Hide plugin/theme/menu in the WordPress dashboard area */
function wpdocs_remove_menusTwo() {
remove_menu_page('et_divi_options'); //Divi WP Theme
remove_menu_page('wpseo_dashboard'); //Yoast SEO WP Plugin
remove_menu_page('activity_log_page'); //Activity Log WP Plugin
}
add_action('admin_init', 'wpdocs_remove_menusTwo');
/* Hide plugin/theme/menu in the WordPress dashboard area */
function wpdocs_remove_menusTwo() {
if (get_current_user_id() == 1) {
remove_menu_page('activity_log_page'); //Activity Log WP Plugin
}
}
add_action('admin_init', 'wpdocs_remove_menusTwo');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment