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
To hide a post type menu item from non-admin users:
your_post_type
should be the name of your actual post type.EDIT-
other menu pages you can remove:
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 theadmin_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.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.
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 ;
To hide Woocommerce submenus under the top-level menu “Products” for all Shop Manager user roles (WordPress 5.1.1):
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: