Reputation: 1011
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?
Upvotes: 0
Views: 1461
Reputation: 2462
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 ); ?>
Upvotes: 2
Reputation: 1793
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
Upvotes: 0
Reputation: 444
Use userphoto_thumbnail() and pass the user ID explicitly.
Usage:
userphoto_thumbnail($user, $before = '', $after = '', $attributes = array(), $default_src = '')
Upvotes: 0