bb_recount_forum_topics

The BuddyPress bb recount forum topics function.

Description

bb_recount_forum_topics(); 

Usage

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

Defined (1)

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

/bp-forums/bbpress/bb-admin/includes/functions.bb-recount.php  
  1. function bb_recount_forum_topics() 
  2. global $bbdb; 
  3.  
  4. $statement = __( 'Counting the number of topics in each forum… %s' ); 
  5. $result = __( 'Failed!' ); 
  6.  
  7. $sql = "INSERT INTO `$bbdb->forums` (`forum_id`, `topics`) (SELECT `forum_id`, COUNT(`topic_status`) as `topics` FROM `$bbdb->topics` WHERE `topic_status` = '0' GROUP BY `forum_id`) ON DUPLICATE KEY UPDATE `topics` = VALUES(`topics`);"; 
  8. if ( is_wp_error( $bbdb->query( $sql ) ) ) { 
  9. return array( 1, sprintf( $statement, $result ) ); 
  10.  
  11. $result = __( 'Complete!' ); 
  12. return array( 0, sprintf( $statement, $result ) );