I have a custom user that i'm trying to minimize access for. I have a few admin menus in the toolbar that I'd like removed but only for this customer user role. I currently have it working for everyone that isn't an admin but I can't get the if function correct by user role. My current code:
//Remove admin menu items if not admin
function remove_admin_bar_links() {
global $wp_admin_bar, $current_user;
if ($current_user->ID != 1) {
$wp_admin_bar->remove_menu('updates'); // Remove the updates link
$wp_admin_bar->remove_menu('comments'); // Remove the comments link
$wp_admin_bar->remove_menu('new-content'); // Remove the content link
$wp_admin_bar->remove_menu('wp-logo'); // Remove the WP Logo link
$wp_admin_bar->remove_menu('wpseo-menu'); // Remove the Yoast SEO menu
}
}
add_action( 'wp_before_admin_bar_render', 'remove_admin_bar_links' );