buddyboss_theme_recently_active_widget_heartbeat( $response = array(),  $data = array() )

Periodically update members list for recently active members widget.

Description

Source

File: bp-members/classes/class-bp-core-recently-active-widget.php

function buddyboss_theme_recently_active_widget_heartbeat( $response = array(), $data = array()  ){
	global $members_template;

	if ( empty( $data['boss_recently_active_widget'] ) ) {
		return $response;
	}

	$number = (int) $data['boss_recently_active_widget'];

	ob_start();

	// Setup args for querying members.
	$members_args = array(
		'user_id'         => 0,
		'type'            => 'active',
		'per_page'        => $number,
		'max'             => $number,
		'populate_extras' => true,
		'search_terms'    => false,
	);

	// 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(); ?>" title="<?php bp_member_name(); ?>" class="bp-tooltip" data-bp-tooltip-pos="up" data-bp-tooltip="<?php bp_member_name(); ?>"><?php bp_member_avatar(); ?></a>
                </div>

			<?php endwhile; ?>

        </div>
        <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 else: ?>

        <div class="widget-error">
			<?php esc_html_e( 'There are no recently active members', 'buddyboss' ); ?>
        </div>

	<?php endif; ?>

	<?php

	// Restore the global.
	$members_template = $old_members_template;

	$response['boss_recently_active_widget'] = ob_get_clean();
	return $response;
}

Changelog

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.