Skip to content

Instantly share code, notes, and snippets.

@levantoan
Created October 22, 2015 15:02
Show Gist options
  • Save levantoan/29b5fccbe9c4a67ffbd8 to your computer and use it in GitHub Desktop.
Save levantoan/29b5fccbe9c4a67ffbd8 to your computer and use it in GitHub Desktop.
Ẩn menu đối với một số user nhất định
<?php
/*
Add this code to functions.php
*/
function remove_admin_menu()
{
//except list user
$admins = array(
'admin',
);
$current_user = wp_get_current_user();
if( !in_array( $current_user->user_login, $admins ) )
{
remove_menu_page('edit.php?post_type=acf');
remove_menu_page('tools.php');
remove_menu_page('edit-comments.php');
remove_menu_page('plugins.php');
remove_menu_page('users.php');
//Remove menu post type
remove_menu_page('itsec');
remove_menu_page( 'wpcf7' );
//Remove Sub menu
global $submenu;
unset($submenu['themes.php'][6]); // Customize
}
}
add_action( 'admin_menu', 'remove_admin_menu', 999 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment