bp_get_message_thread_total_count

Get the current thread's total message count.

Description

(int) bp_get_message_thread_total_count( (bool) $thread_id = false ); 

Returns (int)

Parameters (1)

0. $thread_id — Optional. (bool) => false
ID of the thread. Defaults to current thread ID.

Usage

  1. if ( !function_exists( 'bp_get_message_thread_total_count' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'buddypress/bp-messages/bp-messages-template.php'; 
  3.  
  4. // Optional. ID of the thread. 
  5. // Defaults to current thread ID. 
  6. $thread_id = false; 
  7.  
  8. // NOTICE! Understand what this does before running. 
  9. $result = bp_get_message_thread_total_count($thread_id); 
  10.  

Defined (1)

The function is defined in the following location(s).

/bp-messages/bp-messages-template.php  
  1. function bp_get_message_thread_total_count( $thread_id = false ) { 
  2. if ( false === $thread_id ) { 
  3. $thread_id = bp_get_message_thread_id(); 
  4.  
  5. $thread_template = new BP_Messages_Thread_Template( $thread_id, 'ASC', array( 
  6. 'update_meta_cache' => false 
  7. ) ); 
  8.  
  9. $count = 0; 
  10. if ( ! empty( $thread_template->message_count ) ) { 
  11. $count = intval( $thread_template->message_count ); 
  12.  
  13. /** 
  14. * Filters the current thread's total message count. 
  15. * @since 2.2.0 
  16. * @since 2.6.0 Added the `$thread_id` parameter. 
  17. * @param int $count Current thread total message count. 
  18. * @param int $thread_id ID of the queried thread. 
  19. */ 
  20. return apply_filters( 'bp_get_message_thread_total_count', $count, $thread_id );