BuddyPress Member Gallery Of Users Who Uploaded An Avatar

If you want to encourage the members to upload their avatar/photo or if you are looking for an efficient way to efficiently list users who have uploaded an avatar (The BuddyPress recent members widget doesn’t bother to check if a user has uploaded an avatar), this simple code will allow you to showcase the list of members who have uploaded their avatar.

This is a quick tutorial to show you how to create a custom gallery for your BuddyPress theme that will display members filtered by your choice of parameters.

<?php if ( bp_has_members( array('type'=>'newest', 'per_page'=>500, 'max'=>500) )   ) : ?> 
<?php $count = 1; ?>
<?php while ( bp_members() ) : bp_the_member(); ?>
<?php $user = bp_get_member_user_id(); ?>
<?php if ( bp_get_user_has_avatar ($user) && $count <= 56): ?>
<div class="item-avatar">
<a href="<?php bp_member_permalink() ?>" title="<?php bp_member_name() ?>"><?php bp_member_avatar() ?></a>
</div>
<?php $count = $count + 1; ?>
<?php endif; ?>
<?php endwhile; ?>
<?php endif; ?>

Leave a Reply