bb_update_topic_voices

The BuddyPress bb update topic voices function.

Description

bb_update_topic_voices( $topic_id ); 

Parameters (1)

0. $topic_id
The topic id.

Usage

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

Defined (1)

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

/bp-forums/bbpress/bb-includes/functions.bb-topics.php  
  1. function bb_update_topic_voices( $topic_id ) 
  2. if ( !$topic_id ) { 
  3. return; 
  4.  
  5. $topic_id = abs( (int) $topic_id ); 
  6.  
  7. global $bbdb; 
  8. if ( $voices = $bbdb->get_col( $bbdb->prepare( "SELECT DISTINCT poster_id FROM $bbdb->posts WHERE topic_id = %s AND post_status = '0';", $topic_id ) ) ) { 
  9. $voices = count( $voices ); 
  10. bb_update_topicmeta( $topic_id, 'voices_count', $voices );