BP_Messages_Message::get_last_sent_for_user( int $thread_id )

Get the ID of the message last sent by the logged-in user for a given thread.

Description

Parameters

$thread_id

(Required) ID of the thread.

Return

(int|null) ID of the message if found, otherwise null.

Source

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

	public static function get_last_sent_for_user( $thread_id ) {
		global $wpdb;

		$bp = buddypress();

		$query = $wpdb->get_var( $wpdb->prepare( "SELECT id FROM {$bp->messages->table_name_messages} WHERE sender_id = %d AND thread_id = %d ORDER BY date_sent DESC LIMIT 1", bp_loggedin_user_id(), $thread_id ) );

		return is_numeric( $query ) ? (int) $query : $query;
	}

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.