bp_groups_prime_mentions_results()

Mentions results for groups.

Description

Source

File: bp-groups/bp-groups-functions.php

function bp_groups_prime_mentions_results() {

	// Stop here if user is not logged in.
	if ( ! is_user_logged_in() ) {
		return;
	}

	// Bail if single group page.
	if ( ! bp_is_group() ) {
		return;
	}

	$members = groups_get_group_members( array( 'exclude_admins_mods' => false, 'exclude' => get_current_user_id(), 'per_page' => 10, 'page' => 1 ) );
	$results = array();

	if ( ! empty( $members['members'] ) ) {
		foreach ( $members['members'] as $user ) {
			$result                = new stdClass();
			$result->ID            = bp_activity_get_user_mentionname( $user->ID );
			$result->user_nicename = $user->user_nicename;
			$result->image         = bp_core_fetch_avatar(
					array(
							'html'    => false,
							'item_id' => $user->ID,
					)
			);
			if ( ! empty( $user->display_name ) && ! bp_disable_profile_sync() ) {
				$result->name = bp_core_get_user_displayname( $user->ID );
			} else {
				$result->name = bp_core_get_user_displayname( $user->ID );
			}
			$result->user_id = $user->ID;

			$results[] = $result;
		}

		wp_localize_script(
			'bp-mentions',
			'BP_Suggestions',
			array(
				'members' => $results,
			)
		);
	}
}

Changelog

Changelog
Version Description
BuddyBoss 1.4.4 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.