Last active
July 25, 2024 15:50
-
-
Save barbwiredmedia/20f8444521f30436d8b81824ee1a2d75 to your computer and use it in GitHub Desktop.
Edit and Hide Admin menu items admin_menu & admin_bar_menu. Also hide items from the item bar
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
function remove_acf_menu() | |
{ | |
// provide a list of usernames who can edit custom field definitions here | |
$admins = array( | |
'admin', | |
'levy-admin', | |
'barb' | |
); | |
// get the current user | |
$current_user = wp_get_current_user(); | |
// match and remove if needed | |
if( !in_array( $current_user->user_login, $admins ) ) | |
{ | |
remove_menu_page('edit.php?post_type=acf'); //ACF | |
remove_menu_page('tools.php'); //Tools | |
remove_menu_page('edit-comments.php'); //Comments | |
remove_menu_page('edit.php'); //Edit | |
remove_menu_page('admin.php?page=acf-options'); //ACF Options | |
remove_menu_page('acf-options'); //ACF Options | |
} | |
} | |
add_action( 'admin_menu', 'remove_acf_menu',999 ); | |
//Remove Items from Top Menu | |
add_action( 'admin_bar_menu', 'remove_wp_logo', 999 ); | |
function remove_wp_logo( $wp_admin_bar ) { | |
$wp_admin_bar->remove_node( 'comments' ); | |
$wp_admin_bar->remove_node( 'wpseo-menu' ); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment