BP_Friends_Friendship::get_bulk_last_active( array $user_ids )

Get the last active date of many users at once.


Parameters Parameters

$user_ids

(array) (Required) IDs of users whose last_active meta is being queried.


Top ↑

Return Return

(array) $retval Array of last_active values + user_ids.


Source Source

File: bp-friends/classes/class-bp-friends-friendship.php

	public static function get_bulk_last_active( $user_ids ) {
		global $wpdb;

		$last_activities = BP_Core_User::get_last_activity( $user_ids );

		// Sort and structure as expected in legacy function.
		usort( $last_activities, function( $a, $b ) {
			if ( $a['date_recorded'] == $b['date_recorded'] ) {
				return 0;
			}

			return ( strtotime( $a['date_recorded'] ) < strtotime( $b['date_recorded'] ) ) ? 1 : -1;
		} );

		$retval = array();
		foreach ( $last_activities as $last_activity ) {
			$u = new stdClass;
			$u->last_activity = $last_activity['date_recorded'];
			$u->user_id       = $last_activity['user_id'];

			$retval[] = $u;
		}

		return $retval;
	}


Top ↑

Changelog Changelog

Changelog
Version Description
1.0.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.