0

I use the famous User Photo plugin for my Wordpress site. I want to display the current logged in user's avatar outside the loop. How is this possible?

The current code I use to display the author avatar inside the loop is:

<?php userphoto_the_author_thumbnail('', '', array(width => '40', height => '40')); ?>

Google did not give me much to go on. One person referred to this code:

global $authordata;
$authordata=get_userdata(get_query_var( 'author' ));
userphoto_the_author_thumbnail();

But it did not work. What is the solution?

Gary Woods
  • 1,011
  • 1
  • 15
  • 33

3 Answers3

2

Try the below code.

It will select the current logged-in user's email and then display the avatar.

<?php
    wp_get_current_user();
    $current_user_email = $current_user->user_email;
?>
<?php echo get_avatar( '$current_user_email', 40 ); ?>
Libin
  • 2,442
  • 3
  • 20
  • 31
0

Use userphoto_thumbnail() and pass the user ID explicitly.

Usage:

userphoto_thumbnail($user, $before = '', $after = '', $attributes = array(), $default_src = '')
Gabriel Harper
  • 434
  • 3
  • 4
0

Please try one of thes two.

userphoto($user, $before = '', $after = '', $attributes = array(), $default_src = '')

or

userphoto_thumbnail($user, $before = '', $after = '', $attributes = array(), $default_src = '')

Both function work same as userphoto_the_author_thumbnail

thanks

Er. Anurag Jain
  • 1,780
  • 1
  • 11
  • 19
  • How do I get the width/height in there? If you look at my original code, you will see: **array(width => '40', height => '40'** – Gary Woods Sep 10 '12 at 13:10
  • `$attributes` is for different parameter,you can assign `width,height,style` different in it. for eg. $attributes = `aeeat('width'=>40,'height'=>40,'style'=>'border:0')`. – Er. Anurag Jain Sep 10 '12 at 13:24