I want to show avatar from the post author. I use Ultimate Members and want to show the avatars that are defined via UM.

global $post;
$url = get_avatar_url( $post, array( 'size' => 48 ));
$img = '<img alt="" src="'. $url .'">';
echo $img;

But this code shows the gravatars or default avatar. How can I get the avatars from Ultimate Member?


To get user's avatars of the UM plugin, you have to do this :

// Returns a given user's avatar
um_get_user_avatar_url( $user_id = '', $size = '96' )
  • If i use your code, i get the default avatar URL: <img alt="" src="http://gravatar.com/avatar/d41d8cd98f00b204e9800998ecf8427e?s=400&amp;r=G&amp;d=http://work.cultural-managers.net/wp-content/plugins/ultimate-member/assets/img/default_avatar.jpg"> – Max Mustermann Nov 6 '18 at 17:41
  • I tried these codes: $url = um_get_user_avatar_url( $user_id = '', $size = '96' ); $url = um_get_user_avatar_url( $user_id = '$my_post->post_author', $size = '96' ); and get the default avatar URL. – Max Mustermann Nov 6 '18 at 17:45

Moderator has delete this answer, but this code work:

get_avatar( get_the_author_meta( 'user_email' ), 48 );

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.