bb_get_topic_voices

The BuddyPress bb get topic voices function.

Description

bb_get_topic_voices( (int) $id = 0 ); 

Parameters (1)

0. $id — Optional. (int)
The id.

Usage

  1. if ( !function_exists( 'bb_get_topic_voices' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'buddypress/bp-forums/bbpress/bb-includes/functions.bb-template.php'; 
  3.  
  4. // The id. 
  5. $id = -1; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = bb_get_topic_voices($id); 
  9.  

Defined (1)

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

/bp-forums/bbpress/bb-includes/functions.bb-template.php  
  1. function bb_get_topic_voices( $id = 0 ) { 
  2. $topic = get_topic( get_topic_id( $id ) ); 
  3.  
  4. if ( empty( $topic->voices_count ) ) { 
  5. global $bbdb; 
  6.  
  7. if ( $voices = $bbdb->get_col( $bbdb->prepare( "SELECT DISTINCT poster_id FROM $bbdb->posts WHERE topic_id = %s AND post_status = '0';", $topic->topic_id ) ) ) { 
  8. $voices = count( $voices ); 
  9. bb_update_topicmeta( $topic->topic_id, 'voices_count', $voices ); 
  10. } else { 
  11. $voices = $topic->voices_count; 
  12.  
  13. return apply_filters( 'bb_get_topic_voices', $voices, $topic->topic_id );