BP_Core_User::delete_last_activity( int $user_id )

Delete a user’s last_activity value.

Description

Parameters

$user_id

(int) (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

	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.