When placed in functions.php, this code will hide either top level menu pages or sub-menu pages.
This is a WordPress function that removes pages from the admin menu. The one argument is the URL used to access the page. Some examples are shown, but this can be achieved by visiting any link in WordPress admin, and adding in the url after ‘/wp-admin/’ as an argument for the function.
add_action( ‘admin_menu’, ‘remove_menu_items’ );
This hook is called whenever the admin menu is shown, and runs our custom function ‘remove_menu_items’.
This function works the same as remove_menu_page above, but will remove only a sub-menu admin item.
These WordPress functions can be combined with other functions to create situations where certain pages are only hidden from specific users or user levels. Look at this post to find out how to trigger functions based on the logged in user.