It was much easier than I thought.
I solved the problem by insert this code in function.php (sources at the bottom):
// First: I create the function that allows me to retrieve the user role
function appthemes_check_user_role( $role, $user_id = null ) {
if ( is_numeric( $user_id ) ) {
$user = get_userdata( $user_id );
} else {
$user = wp_get_current_user();
}
if ( empty( $user ) ) {
return false;
}
return in_array( $role, (array) $user->roles );
}
// Second: I create and enable function that removes "G Hook Guide" button from the admin-bar of the users with role "my_role"
add_action( 'wp_before_admin_bar_render', 'admin_bar_edit' );
function admin_bar_edit() {
if ( appthemes_check_user_role( 'my_role' )) {
global $wp_admin_bar;
$wp_admin_bar->remove_menu('ghooks');
}
}
In my language we say: “Chi fa da sè fa per tre” ??
Sources:
https://docs.appthemes.com/tutorials/wordpress-check-user-role-function/
https://www.paulund.co.uk/how-to-remove-links-from-wordpress-admin-bar