BP_Messages_Thread::get_user_last_deleted_message( int $thread_id )

Get the user’s last deleted message in thread

Description

Parameters

$thread_id

(Required)

Source

File: bp-messages/classes/class-bp-messages-thread.php

	public static function get_user_last_deleted_message( $thread_id ) {
		global $wpdb;
		$bp = buddypress();

		$results = $wpdb->get_results( $wpdb->prepare(
			"SELECT m.* FROM {$bp->messages->table_name_messages} m
			LEFT JOIN {$bp->messages->table_name_meta} mm ON m.id = mm.message_id
			WHERE m.thread_id = %d
			AND (
				mm.meta_key = 'deleted_by' AND mm.meta_value = %d
			)
			ORDER BY m.date_sent DESC, m.id DESC
			LIMIT 1
		", $thread_id, bp_loggedin_user_id() ) );

		if ( ! empty( $results ) ) {
			static::$last_deleted_message = (object) $results[0];
		}

		return static::$last_deleted_message;
	}

Changelog

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