bp_core_get_last_activity( int|string $last_activity_date = '', string $string = '' )

Format last activity string based on time since date given.

Description

Parameters

$last_activity_date

(Optional) The date of last activity.

Default value: ''

$string

(Optional) A sprintf()-able statement of the form 'active %s'.

Default value: ''

Return

(string) $last_active A string of the form '3 years ago'.

Source

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

function bp_core_get_last_activity( $last_activity_date = '', $string = '' ) {

	// Setup a default string if none was passed.
	$string = empty( $string )
		? '%s'     // Gettext placeholder.
		: $string;

	// Use the string if a last activity date was passed.
	$last_active = empty( $last_activity_date )
		? __( 'Not recently active', 'buddyboss' )
		: sprintf( $string, bp_core_time_since( $last_activity_date ) );

	/**
	 * Filters last activity string based on time since date given.
	 *
	 * @since BuddyPress 1.2.0
	 *
	 * @param string $last_active        Last activity string based on time since date given.
	 * @param string $last_activity_date The date of last activity.
	 * @param string $string             A sprintf()-able statement of the form 'active %s'.
	 */
	return apply_filters( 'bp_core_get_last_activity', $last_active, $last_activity_date, $string );
}

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.