friends_get_newest( int $user_id, int $per_page, int $page, string $filter = '' )

Get a user’s friends, in the order in which they joined the site.

Description

See also

Parameters

$user_id

(int) (Required) ID of the user whose friends are being retrieved.

$per_page

(int) (Optional) Number of results to return per page. Default: 0 (no pagination; show all results).

$page

(int) (Optional) Number of the page of results to return. Default: 0 (no pagination; show all results).

$filter

(string) (Optional) Limit results to those matching a search string.

Default value: ''

Return

(array) See BP_Core_User::get_users().

Source

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

function friends_get_newest( $user_id, $per_page = 0, $page = 0, $filter = '' ) {
	$friends = bp_core_get_users( array(
		'type'         => 'newest',
		'per_page'     => $per_page,
		'page'         => $page,
		'user_id'      => $user_id,
		'search_terms' => $filter,
	) );

	/**
	 * Filters a user's friends listed from newest to oldest.
	 *
	 * @since BuddyPress 1.2.0
	 *
	 * @param array $friends {
	 *     @type int   $total_users Total number of users matched by query params.
	 *     @type array $paged_users The current page of users matched by query params.
	 * }
	 */
	return apply_filters( 'friends_get_newest', $friends );
}

Changelog

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.