Hi,
Thanks !
I found another way by using the standard WP “get_avatar” filter : it gives the user Id as an argument and I’m able to get the user role and add my now class to the avatar.
COPY CODE
add_filter('get_avatar','change_avatar_css', 10, 5);
function change_avatar_css($class, $id_or_email, $size, $default, $alt) {
$class = str_replace('class="avatar', 'class="avatar-bs-role-'.bs_user_customrole($id_or_email).' avatar', $class) ;
return $class;
}