bp_has_message_threads( array|string $args = array() )
Retrieve private message threads for display in inbox/sentbox/notices.
Description
Similar to WordPress’s have_posts() function, this function is responsible for querying the database and retrieving private messages for display inside the theme via individual template parts for a member’s inbox/sentbox/notices.
Parameters
- $args
-
(Optional) Array of arguments. All are optional.
- 'user_id'
(int) ID of the user whose threads are being loaded. Default: ID of the logged-in user. - 'box'
(string) Current "box" view. If not provided here, the current view will be inferred from the URL. - 'per_page'
(int) Number of results to return per page. Default: 10. - 'max'
(int) Max results to return. Default: false. - 'type'
(string) Type of messages to return. Values: 'all', 'read', 'unread' Default: 'all' - 'search_terms'
(string) Terms to which to limit results. Default: the value of $_REQUEST['s']. - 'page_arg'
(string) URL argument used for the pagination param. Default: 'mpage'. - 'meta_query'
(array) Meta query arguments. Only applicable if $box is not 'notices'. See WP_Meta_Query more details.
Default value: array()
- 'user_id'
Return
(bool) True if there are threads to display, otherwise false.
Source
File: bp-messages/bp-messages-template.php
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 | function bp_has_message_threads( $args = array () ) { global $messages_template ; // The default box the user is looking at. $current_action = bp_current_action(); switch ( $current_action ) { case 'notices' : case 'inbox' : $default_box = $current_action ; break ; default : $default_box = 'inbox' ; break ; } // User ID // @todo displayed user for moderators that get this far? $user_id = bp_displayed_user_id()?:bp_loggedin_user_id(); // Search Terms. $search_terms = isset( $_REQUEST [ 's' ] ) ? stripslashes ( $_REQUEST [ 's' ] ) : '' ; // Parse the arguments. $r = bp_parse_args( $args , array ( 'user_id' => $user_id , 'box' => $default_box , 'per_page' => 10, 'max' => false, 'type' => 'all' , 'search_terms' => $search_terms , 'include' => false, 'meta_query' => array () ), 'has_message_threads' ); // Load the messages loop global up with messages. $messages_template = new BP_Messages_Box_Template( $r ); /** * Filters if there are any message threads to display in inbox/sentbox/notices. * * @since BuddyPress 1.1.0 * * @param bool $value Whether or not the message has threads. * @param BP_Messages_Box_Template $messages_template Current message box template object. * @param array $r Array of parsed arguments passed into function. */ return apply_filters( 'bp_has_message_threads' , $messages_template ->has_threads(), $messages_template , $r ); } |
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.