BP_Core_User::delete_last_activity( int $user_id )

Delete a user’s last_activity value.

Description

Parameters

$user_id

(Required) ID of the user whose activity should be deleted.

Return

(bool) True on success, false on failure or if no last_activity is found for the user.

Source

File: bp-core/classes/class-bp-core-user.php

971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
public static function delete_last_activity( $user_id ) {
    global $wpdb;
 
    $existing = self::get_last_activity( $user_id );
 
    if ( empty( $existing ) || empty( $existing[ $user_id ]['activity_id'] ) ) {
        return false;
    }
 
    $deleted = $wpdb->delete(
        buddypress()->members->table_name_last_activity,
 
        // WHERE.
        array(
            'id' => $existing[ $user_id ]['activity_id'],
        ),
 
        // WHERE sanitization format.
        array(
            '%s',
        )
    );
 
    wp_cache_delete( $user_id, 'bp_last_activity' );
 
    return $deleted;
}

Changelog

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