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 Description


Parameters Parameters

$thread_id

(Required) ID of the thread.


Top ↑

Return Return

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


Top ↑

Source 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;
	}

Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.