The site members loop can be used to output a list of users that are registered on your site.
Standard Loop
<?php if ( bp_has_site_members() ) : ?>
<div class="pag-count" id="member-dir-count">
<?php bp_site_members_pagination_count() ?>
</div>
<div class="pagination-links" id="member-dir-pag">
<?php bp_site_members_pagination_links() ?>
</div>
<ul id="members-list" class="item-list">
<?php while ( bp_site_members() ) : bp_the_site_member(); ?>
<li>
<!-- Some example template tags you can use -->
<?php bp_the_site_member_link() ?>
<?php bp_the_site_member_avatar() ?>
<?php bp_the_site_member_name() ?>
<?php bp_the_site_member_last_active() ?>
<?php bp_the_site_member_add_friend_button() ?>
</li>
<?php endwhile; ?>
</ul>
<?php else: ?>
<div id="message" class="info">
<p>No members found.</p>
</div>
<?php endif; ?>
Accepted Parameters
The bp_has_site_members() function will accept a number of parameters that will manipulate the data being returned.
-
type optional
Defines the type of users to return.
- Accepted arguments:
active,newest,popular,online,alphabetical,random - Default value:
active
- Accepted arguments:
-
per_page optional
The number of users to display on a page before they are paginated to the next page.
- Default value:
10
- Default value:
-
max optional
The total number of users to return.
- Default value:
false(no limit)
- Default value:
Advanced Usage
Fetch the newest users with 20 users per page, up to a total of 60 users.
<?php if ( bp_has_site_members( 'type=newest&amp;amp;per_page=20&amp;amp;max=60' ) ) : ?>