bp_get_user_last_activity( int $user_id )

Get the last activity for a given user.

Description

Parameters

$user_id

(Required) The ID of the user.

Return

(string) Time of last activity, in 'Y-m-d H:i:s' format, or an empty string if none is found.

Source

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

1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
function bp_get_user_last_activity( $user_id = 0 ) {
    $activity = '';
 
    $last_activity = BP_Core_User::get_last_activity( $user_id );
    if ( ! empty( $last_activity[ $user_id ] ) ) {
        $activity = $last_activity[ $user_id ]['date_recorded'];
    }
 
    /**
     * Filters the last activity for a given user.
     *
     * @since BuddyPress 1.9.0
     *
     * @param string $activity Time of last activity, in 'Y-m-d H:i:s' format or
     *                         an empty string if none found.
     * @param int    $user_id  ID of the user being checked.
     */
    return apply_filters( 'bp_get_user_last_activity', $activity, $user_id );
}

Changelog

Changelog
Version Description
BuddyPress 1.9.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.