You can use the following hook to hide the menu items (products and lists) of our plug-in for non-administrative users.
Add the following hook to your functions.php:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
function atkp_hide_menu(){ if(is_user_logged_in() && !current_user_can('administrator')){ remove_menu_page( 'edit.php?post_type=atkp_product' ); remove_menu_page( 'edit.php?post_type=atkp_list' ); } } add_action('admin_init', 'atkp_hide_menu'); function atkp_admin_bar_render() { if(is_user_logged_in() && !current_user_can('administrator')){ global $wp_admin_bar; $wp_admin_bar->remove_menu('new-atkp_product'); $wp_admin_bar->remove_menu('new-atkp_list'); } } add_action( 'wp_before_admin_bar_render', 'atkp_admin_bar_render' ); |
Tip: Use a plugin like My Custom Functions or a child theme to build your hooks!