Remove WP Admin Menu Items by User Role


How do I make it so that a menu on the WP Admin menu bar is only visible to specified user roles?

I have this code which works to remove WP Admin menu items from all users. Is there any way to customize it so that only certain user roles can view these menu item? Thank you!

function shapeSpace_remove_toolbar_menu() {
    global $wp_admin_bar;
add_action('wp_before_admin_bar_render', 'shapeSpace_remove_toolbar_menu', 999);
user2421252 4 years 2020-03-07T19:56:23-05:00 0 Answers 105 views 0

Leave an answer