Created
July 29, 2022 11:40
-
-
Save MrJoshFisher/a2695441fdc21e8de5fa72ee92eae0fb to your computer and use it in GitHub Desktop.
[Remove Pages, Menu Items, Notifications from Wordpress Admin] #wordpress
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
add_action( 'admin_bar_menu', 'remove_wp_nodes', 999 ); | |
function remove_wp_nodes() | |
{ | |
global $user_ID; | |
global $wp_admin_bar; | |
if ( current_user_can( 'editor' ) ) { | |
$wp_admin_bar->remove_menu('wp-logo'); | |
$wp_admin_bar->remove_menu('comments'); | |
$wp_admin_bar->remove_menu('new-content'); | |
// $wp_admin_bar->remove_node( 'new-post' ); | |
// $wp_admin_bar->remove_node( 'new-link' ); | |
// $wp_admin_bar->remove_node( 'new-media' ); | |
// $wp_admin_bar->remove_node( 'new-page' ); | |
// $wp_admin_bar->remove_node( 'new-liquid-header' ); | |
// $wp_admin_bar->remove_node( 'new-liquid-footer' ); | |
// $wp_admin_bar->remove_node( 'new-liquid-mega-menu' ); | |
// $wp_admin_bar->remove_node( 'new-liquid-portfolio' ); | |
// $wp_admin_bar->remove_node( 'new-tablepress-table' ); | |
} | |
} | |
add_action( 'admin_init', 'my_remove_menu_pages' ); | |
function my_remove_menu_pages() { | |
global $user_ID; | |
if ( current_user_can( 'editor' ) ) { | |
remove_menu_page( 'edit.php?post_type=liquid-header' ); | |
remove_menu_page( 'edit.php?post_type=liquid-footer' ); | |
remove_menu_page( 'edit.php?post_type=liquid-mega-menu' ); | |
remove_menu_page( 'edit.php?post_type=liquid-portfolio' ); | |
remove_menu_page( 'vc-welcome' ); | |
remove_menu_page( 'wpcf7' ); | |
remove_menu_page( 'tablepress' ); | |
remove_menu_page( 'index.php' ); //Dashboard | |
remove_menu_page( 'jetpack' ); //Jetpack* | |
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 | |
} | |
} | |
function my_hide_notices_to_all_but_super_admin(){ | |
global $user_ID; | |
if ( current_user_can( 'editor' ) ) { | |
remove_all_actions( 'user_admin_notices' ); | |
remove_all_actions( 'admin_notices' ); | |
} | |
} | |
add_action('in_admin_header', 'my_hide_notices_to_all_but_super_admin', 99); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment