Support » Plugin: User Avatar » [Plugin: User Avatar] How to place avatar on author's page template?

Viewing 8 replies - 1 through 8 (of 8 total)
  • Sorry for bumping, but anyone have an idea?
    Thanks! 🙂

    You can retrieve the avatar of any user by this function:

    <?php echo get_avatar( $id_or_email, $size, $default, $alt ); ?>

    For example inside the loop of author.php template to display the avatar in 60px size, the code is :

    <?php echo get_avatar(get_the_author_meta('ID'),60,'',get_the_author_meta('display_name')); ?>

    Hey Dawn, thanks for you reply. For some reason that doesn’t seem to work.
    Based on your code, I modified it like this (but your original code unfortunately also didn’t work):
    <?php echo get_avatar( get_the_author_meta($curauth->ID), '100' ); ?>
    Could it be a problem that I’m trying to display the avatar outside the loop?

    I think yes because the function get_the_author_meta(‘ID’) shoud be used inside the loop to get the author ID , which is used in get_avatar() to get the avatar of this ID, as if u want to display the avatar of the ID 2 user the code then is :
    <?php echo get_avatar(2, '100' ); ?>

    Hm, maybe I didn’t fully understand the concept of the author.php file, but it doesn’t call for the loop at all. And displaying all other user meta data works fine.
    I’m using $curauth->something; and also

    <?php $user_id = $curauth->ID;
      $key = 'some_field';
      $single = true;
      $the_info_i_want = get_user_meta( $user_id, $key, $single );
      echo '<p><em>'. $the_info_i_want . '</em></p>';

    Both work just fine. Isn’t the avatar also just some kind of user meta data and hence it should be possible to call it outside the loop?

    So, did actually anybody make this work with the User Avatar plugin?

    I am starting to wonder if this is maybe not possible with this plugin?
    Because when I very simply hard-code
    <?php echo get_avatar(2, '100' ); ?>
    to my author.php (user no. 2 exists and I uploaded an avatar using this plugin) the code that is being inserted to my page is the default wordpress avatar path.
    Something like
    <img alt='' src='http://myserver/wp-includes/images/blank.gif' class='avatar avatar-100 photo avatar-default' height='100' width='100' />
    So it definitely is not pointing to the path of this plugin.

    I would really appreciate help cos I’m totally stuck. 🙂

    My theme’s default avatar code just worked. Didn’t have to replace it with any of the hacks mentioned above.

    Tip: Go to settings>discussions and enable ‘Show avatars’ in most cases this is the culprit. Hope this helps.

    Use $curauth->ID instead in the get_avatar code. So:

    <?php echo get_avatar($curauth->ID, 95, get_bloginfo(‘template_url’).’/images/no-avatar.png’); ?>

    That finally worked for me.

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘[Plugin: User Avatar] How to place avatar on author's page template?’ is closed to new replies.