Skip to:
Content
Pages
Categories
Search
Top
Bottom

Re: How to display specific user\\\'s avatar?


John James Jacoby
Keymaster

@johnjamesjacoby

I’ve done something like this in the past… It all depends on which file you’re trying to do this in, and in which loop so you know what data you have available to you…

In a post loop, you can use the global $authordata to get the authors ID.

// Code borrowed from bp_adminbar_authors_menu()
function bp_author_link() {
global $authordata;

// Get author's data BuddyPress style
$author = new BP_Core_User( $authordata->ID );

echo '<a href="' . $author->user_url . '">';
echo $author->avatar_mini;
echo ' ' . $author->fullname;
echo '<span class="activity">' . $author->last_active . '</span>';
echo '</a>';
}

This way it’s tucked in a function that can be re-used in various other pages and ways.

Skip to toolbar