• Hi Bangbay thanks for creating an amazing avatar plugin, unfortunately am having a problem displaying user avatar on their profile page.

    I have created a page that only display user info and avatar photo. using this code echo get_wp_user_avatar($user_id, 'medium');
    it dasn’t display users upload avatar photo but only the Default Avatar..?

    I have also tried this code to echo get_wp_user_avatar($post->post_author, 96);
    does the same thing it only display the Default avatar.

    what i would like to do is if u view user profile page show their uploaded avatar photo.

    Thank you for your tima Bangbay

    http://ww.wp.xz.cn/plugins/wp-user-avatar/

Viewing 4 replies - 1 through 4 (of 4 total)
  • Try this code instead:

    <?php
      $user = get_user_by('slug', $author_name);
      echo get_wp_user_avatar($user->ID, 96);
    ?>
    Thread Starter oshi

    (@thugzanime)

    Hi Bangbay thanks for getting back at me ASAP great support.

    unfortunately the code you provide didn’t do the trick. it just display the Default Avatar, a little dude with a mustache.

    it is obviously the code you have proved it seem to be working but only displaying the Default plugin avatar. not the user uploaded photo (avatar)

    Thank you so much for the support u giving me ^_^

    Thread Starter oshi

    (@thugzanime)

    I have tried this it display the user uploaded avatar photo but if the user logout it shows the Default avatar of wp user avatar

    here is the code
    global $current_user;echo get_avatar( $current_user->ID, 64 );

    You need to pass the correct user ID to the code, but I’m unclear about how your page is set up. Let me step back and explain to you what the different codes you’ve tried will do:

    This is the general structure of the code, but you need to set the value of $user_id, such as $user_id = get_the_author_meta('ID');:

    $user_id = get_the_author_meta('ID');
    echo get_wp_user_avatar($user_id, 'medium');

    If you use this code within The Loop, this will return the avatar for the author of the post/page.

    echo get_wp_user_avatar(get_the_author_meta('ID'), 96);

    This was a code I suggested to someone who was trying to get the author of a post/page outside of The Loop:

    echo get_wp_user_avatar($post->post_author, 96);

    This code works if it’s an author page (http://{yoursite}/author/your-username):

    $user = get_user_by('slug', $author_name);
    echo get_wp_user_avatar($user->ID, 96);

    The last code you’ve tried gets the ID of the current logged-in user, so yes it will not retrieve the correct user ID if you are logged out:

    global $current_user;echo get_avatar( $current_user->ID, 64 );

    So, with that in mind, how are you displaying other user info? If you already know how to display user’s name, etc., then it should be simple to grab the correct user ID.

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘Shortcode works only for Default Avatar?’ is closed to new replies.