Last active
September 9, 2017 15:19
-
-
Save wpmark/8160972 to your computer and use it in GitHub Desktop.
Remove WordPress admin menu items for certain users.
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
<?php | |
/* add our function to the admin meny action */ | |
add_action( 'admin_menu', 'pxjn_remove_menus', 999 ); | |
function pxjn_remove_menus() { | |
/* get the current user id */ | |
$pxjn_current_user_id = $current_user->ID; // get the user ID | |
/* setup an array of user ids to not be affected */ | |
$pxjn_team_ids = array( 1, 2 ); | |
/* if current user id is not in the allowed array */ | |
if( ! in_array( $pxjn_current_user_id, $pxjn_team_ids ) ) { | |
/* remove the menu items(s) */ | |
remove_menu_page( 'link-manager.php' ); | |
} | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment