What I'm looking to do is completely hide the UI for a custom post type from specific user roles...Ive previously found many resources on how to disable access to using those CPTs but nothing that really allows you to completely hide the CPT UI all together based on what user is logged into the dashboard.

This is important since I need clients to completely stay out of custom post types for the store, and if they can see the store CPT UI in the dashboard still it doesn't make a difference if their capabilities are restricted since their still going to inquire how they can go about adding product on their own as a result.

Id really prefer to not accomplish this with a plugin however if there is something that can do the trick in a non-bloated way that would still be great I suppose.

Thanks for your help, SB

6 Answers 6


To hide a post type menu item from non-admin users:

function wpse28782_remove_menu_items() {
    if( !current_user_can( 'administrator' ) ):
        remove_menu_page( 'edit.php?post_type=your_post_type' );
add_action( 'admin_menu', 'wpse28782_remove_menu_items' );

your_post_type should be the name of your actual post type.


other menu pages you can remove:

remove_menu_page('edit.php'); // Posts
remove_menu_page('upload.php'); // Media
remove_menu_page('link-manager.php'); // Links
remove_menu_page('edit-comments.php'); // Comments
remove_menu_page('edit.php?post_type=page'); // Pages
remove_menu_page('plugins.php'); // Plugins
remove_menu_page('themes.php'); // Appearance
remove_menu_page('users.php'); // Users
remove_menu_page('tools.php'); // Tools
remove_menu_page('options-general.php'); // Settings

EDIT 2 -

Removing plugin menu items.

For plugins, it seems you only need the page= query var. The other thing to note is the priority, which is the third argument to the admin_menu add_action. It has to be set low enough (the higher the number, the lower the priority) so that plugins have already added themselves to the menu.

function wpse28782_remove_plugin_admin_menu() {
    if( !current_user_can( 'administrator' ) ):
add_action( 'admin_menu', 'wpse28782_remove_plugin_admin_menu', 9999 );
  • Such a simple solution, thank you it worked perfectly!
    – Mr.Brown
    Sep 17, 2011 at 19:28
  • Curious, is wpse28782_remove_menu_items a function name you chose at random or is this specific to WP?....Also, how would I go about expanding on this idea and targeting additional CPT's, or for that matter other native WP menu's? Thanks again for the help!
    – Mr.Brown
    Sep 17, 2011 at 19:32
  • 1
    @Mr.Brown - the function name is based on the id of your question (check the url), just something guaranteed to be unique, you can name it whatever you'd like as long as it's not an existing function. you can also add additional remove_menu_page calls to remove other CPTs, as well as other menu items, see my edit.
    – Milo
    Sep 17, 2011 at 20:05
  • So awesome, thanks again. This is an amazing solution.
    – Mr.Brown
    Sep 17, 2011 at 20:06
  • Just one last thing - how do I go about finding the template name thats used for additional menu's from plugins that are currently installed? ie. remove_menu_page('cart_plugin');
    – Mr.Brown
    Sep 17, 2011 at 20:11

The accepted answer can be used to hide custom post types (and other assorted items) as described. But if you want to hide the CPT UI plugin menu itself, you can also remove the action that adds it to the menu in the first place.

if( !current_user_can( 'administrator' ) ) {
    remove_action( 'admin_menu', 'cptui_plugin_menu' );

You can also use the Adminimize plugin. This plugin have options for all post types, meta boxes and many more to hide on different roles. No coding.


If you want to hide that plugin's menu which name is "Custom Post Type UI" a.k.a CPTUI, it is not possible with combining first link with remove_menu_page.

All you have to do is ;

function wpse_28782_remove_menus() {
add_action('admin_init', 'wpse_28782_remove_menus');

To hide Woocommerce submenus under the top-level menu "Products" for all Shop Manager user roles (Wordpress 5.1.1):

function remove_menus_shopmgr(){

// If the current user is a shop manager
if ( current_user_can('shop_manager') ) {

   //removes Products > Categories submenu 
    remove_submenu_page( 'edit.php?post_type=product','edit-tags.php?taxonomy=product_cat&post_type=product' );

   //removes Products > Tags submenu
    remove_submenu_page( 'edit.php?post_type=product','edit-tags.php?taxonomy=product_tag&post_type=product' ); 


add_action( 'admin_menu', 'remove_menus_shopmgr', 999 );

If remove_menu_page doesn't work for you (it didn't for me) then instead of removing the menu, an alternative is to tell WordPress not to show the menu for the post type:

function wpse28782_hide_menu_items() {
    if( !current_user_can( 'administrator' ) ) {
        $post_type = get_post_type_object( 'your_post_type');
        if ($post_type) {
            $post_type->show_in_menu = false;
add_action( 'admin_menu', 'wpse28782_hide_menu_items', 99 );

Not the answer you're looking for? Browse other questions tagged or ask your own question.