BP_REST_Messages_Endpoint::search_thread_items( WP_REST_Request $request )
Search Existing thread by user and recipient for the message.
Description
Parameters
- $request
-
(Required) Full details about the request.
Return
(WP_REST_Response) | WP_Error
Source
File: bp-messages/classes/class-bp-rest-messages-endpoint.php
649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 | public function search_thread_items( $request ) { $user_id = $request ->get_param( 'user_id' ); $recipient_id = ( array ) $request ->get_param( 'recipient_id' ); if ( empty ( $user_id ) ) { $user_id = bp_loggedin_user_id(); } $retval = array (); if ( class_exists ( 'BP_Messages_Message' ) && method_exists( 'BP_Messages_Message' , 'get_existing_thread' ) ) { $thread_id = BP_Messages_Message::get_existing_thread( $recipient_id , $user_id ); if ( ! empty ( $thread_id ) ) { $thread = $this ->get_thread_object( $thread_id ); $retval = $this ->prepare_response_for_collection( $this ->prepare_item_for_response( $thread , $request ) ); } } $response = rest_ensure_response( $retval ); /** * Fires after a thread id is fetched via the REST API. * * @since 0.1.0 * * @param WP_REST_Request $request The request sent to the API. * * @param WP_REST_Response $response The response data. */ do_action( 'bp_rest_messages_search_thread_items' , $response , $request ); return $response ; } |
Changelog
Version | Description |
---|---|
0.1.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.