pixeloft pixeloft - 23 days ago 7
PHP Question

BuddyPress avatar showing up outside designated content

I have a BuddyPress member loop that includes the user avatar. The avatar is showing up, but outside it's wrapping html element.

if ( bp_has_members( bp_ajax_querystring( 'members' ) ) ) :

$content.="<ul>";

while ( bp_members() ) : bp_the_member();

$content.="<li><a href='".bp_member_permalink()."'>".bp_member_avatar()."</a></li>";

endwhile;

$content.="</ul>";

else:

$content.='You are not connected to any companies.';

endif;


The result is showing up with empty

<ul>
<li></li>
</ul>


And the avatars are there, but above the actual list.

enter image description here

Any help would be great!

Answer

This function will echo the avatar: bp_member_avatar(). So it will appear as your code runs, rather than append it to $content. Try using bp_get_member_avatar() instead.