bp_core_ajax_widget_members()
AJAX request handler for Members widgets.
Description
See also
Source
File: bp-members/bp-members-widgets.php
function bp_core_ajax_widget_members() { global $members_template; check_ajax_referer( 'bp_core_widget_members' ); // Setup some variables to check. $filter = ! empty( $_POST['filter'] ) ? $_POST['filter'] : 'recently-active-members'; $max_members = ! empty( $_POST['max-members'] ) ? absint( $_POST['max-members'] ) : 5; // Determine the type of members query to perform. switch ( $filter ) { // Newest activated. case 'newest-members' : $type = 'newest'; break; // Popular by friends. case 'popular-members' : if ( bp_is_active( 'friends' ) ) { $type = 'popular'; } else { $type = 'active'; } break; // Default. case 'recently-active-members' : default : $type = 'active'; break; } // Setup args for querying members. $members_args = array( 'user_id' => 0, 'type' => $type, 'per_page' => $max_members, 'max' => $max_members, 'populate_extras' => true, 'search_terms' => false, ); // Query for members. if ( bp_has_members( $members_args ) ) : ?> <?php echo '0[[SPLIT]]'; // Return valid result. TODO: remove this. ?> <?php while ( bp_members() ) : bp_the_member(); ?> <li class="vcard"> <div class="item-avatar"> <a href="<?php bp_member_permalink() ?>"> <?php bp_member_avatar(); ?> <?php $current_time = current_time( 'mysql', 1 ); $diff = strtotime( $current_time ) - strtotime( $members_template->member->last_activity ); if ( $diff < 300 ) { // 5 minutes = 5 * 60 ?> <span class="member-status online"></span> <?php } ?> </a> </div> <div class="item"> <div class="item-title fn"><a href="<?php bp_member_permalink(); ?>"><?php bp_member_name(); ?></a></div> <div class="item-meta"> <?php if ( 'newest' == $settings['member_default'] ) : ?> <span class="activity" data-livestamp="<?php bp_core_iso8601_date( bp_get_member_registered( array( 'relative' => false ) ) ); ?>"><?php bp_member_registered(); ?></span> <?php elseif ( 'active' == $settings['member_default'] ) : ?> <span class="activity" data-livestamp="<?php bp_core_iso8601_date( bp_get_member_last_active( array( 'relative' => false ) ) ); ?>"><?php bp_member_last_active(); ?></span> <?php else : ?> <span class="activity"><?php bp_member_total_friend_count(); ?></span> <?php endif; ?> </div> </div> <div class="member_last_visit"></div> </li> <?php endwhile; ?> <?php else: ?> <?php echo "-1[[SPLIT]]<li>"; ?> <?php esc_html_e( 'There were no members found, please try another filter.', 'buddyboss' ) ?> <?php echo "</li>"; ?> <?php endif; }
Changelog
Version | Description |
---|---|
BuddyPress 1.0.0 | Introduced. |
Questions?
We're always happy to help with code or other questions you might have! Search our developer docs, contact support, or connect with our sales team.