buddyboss_theme_whos_online_widget_heartbeat( $response = array(), $data = array() )
Periodically update total number of members online for who’s online widget.
Description
Source
File: bp-members/classes/class-bp-core-whos-online-widget.php
function buddyboss_theme_whos_online_widget_heartbeat( $response = array(), $data = array() ){ global $members_template; if ( empty( $data['boss_whos_online_widget'] ) ) { return $response; } $number = (int) $data['boss_whos_online_widget']; ob_start(); // Setup args for querying members. $members_args = array( 'user_id' => 0, 'type' => 'online', 'per_page' => $number, 'max' => $number, 'populate_extras' => true, 'search_terms' => false, ); $total_online = 0; if ( function_exists( 'bp_get_total_online_member_count' ) ){ $total_online = bp_get_total_online_member_count(); } // Back up global. $old_members_template = $members_template; ?> <?php if ( bp_has_members( $members_args ) ) : ?> <div class="avatar-block"> <?php while ( bp_members() ) : bp_the_member(); ?> <div class="item-avatar"> <a href="<?php bp_member_permalink(); ?>" class="bp-tooltip" title="<?php bp_member_name(); ?>" data-bp-tooltip-pos="up" data-bp-tooltip="<?php bp_member_name(); ?>"><?php bp_member_avatar(); ?><span class="member-status online"></span></a> </div> <?php endwhile; ?> </div> <?php if ( $members_template->total_member_count < $total_online ){ ?> <div class="more-block"><a href="<?php bp_members_directory_permalink(); ?>" class="count-more">More<i class="bb-icon-angle-right"></i></a></div> <?php } ?> <?php else: ?> <div class="widget-error"> <?php esc_html_e( 'There are no users currently online', 'buddyboss' ); ?> </div> <?php endif; ?> <?php // Restore the global. $members_template = $old_members_template; $response['boss_whos_online_widget'] = ob_get_clean(); $response['boss_whos_online_widget_total'] = $total_online; return $response; }
Changelog
Version | Description |
---|---|
BuddyBoss 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.