bb_recount_forum_posts

The BuddyPress bb recount forum posts function.

Description

bb_recount_forum_posts(); 

Usage

  1. if ( !function_exists( 'bb_recount_forum_posts' ) ) { 
  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_posts(); 
  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_posts() 
  2. global $bbdb; 
  3.  
  4. $statement = __( 'Counting the number of posts in each forum… %s' ); 
  5. $result = __( 'Failed!' ); 
  6.  
  7. $sql = "INSERT INTO `$bbdb->forums` (`forum_id`, `posts`) (SELECT `forum_id`, COUNT(`post_status`) as `posts` FROM `$bbdb->posts` WHERE `post_status` = '0' GROUP BY `forum_id`) ON DUPLICATE KEY UPDATE `posts` = VALUES(`posts`);"; 
  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 ) );