Forum Replies Created

Viewing 1 post (of 1 total)
  • Author
  • in reply to: Customize avatar style depending on user role #56163
     Bebunch
    Participant

    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;
    }
Viewing 1 post (of 1 total)

Log in with your credentials

Forgot your details?