BP_Messages_Message::get_existing_thread( array $recipient_ids, integer $sender )
Get existsing thread which matches the recipients
Description
Parameters
- $recipient_ids
-
(Required)
- $sender
-
(Required)
Source
File: bp-messages/classes/class-bp-messages-message.php
425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 | public static function get_existing_thread( $recipient_ids , $sender = 0 ) { global $wpdb ; $bp = buddypress(); // add the sender into the recipient list and order by id ascending $recipient_ids [] = $sender ; $recipient_ids = array_filter ( array_unique ( array_values ( $recipient_ids ))); sort( $recipient_ids ); $results = $wpdb ->get_results( $sql = $wpdb ->prepare( "SELECT r.thread_id as thread_id, GROUP_CONCAT(DISTINCT user_id ORDER BY user_id separator ',' ) as recipient_list, MAX(m.date_sent) AS date_sent FROM { $bp ->messages->table_name_recipients} r INNER JOIN { $bp ->messages->table_name_messages} m ON m.thread_id = r.thread_id GROUP BY r.thread_id HAVING recipient_list = %s ORDER BY date_sent DESC LIMIT 1 ", implode( ',' , $recipient_ids ) ) ); if ( ! $results ) { return null; } $thread_id = $results [0]->thread_id; if ( ! $is_active_recipient = BP_Messages_Thread::is_thread_recipient( $thread_id , $sender ) ) { return null; } return $thread_id ; } |
Changelog
Version | Description |
---|---|
BuddyBoss 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.