bb_update_topics_replied

The BuddyPress bb update topics replied function.

Description

bb_update_topics_replied( $user_id ); 

Parameters (1)

0. $user_id
The user id.

Usage

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

Defined (1)

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

/bp-forums/bbpress/bb-includes/functions.bb-users.php  
  1. function bb_update_topics_replied( $user_id ) { 
  2. global $bbdb; 
  3.  
  4. $user_id = (int) $user_id; 
  5.  
  6. if ( !$user = bb_get_user( $user_id ) ) 
  7. return false; 
  8.  
  9. $topics_replied = (int) $bbdb->get_var( $bbdb->prepare( "SELECT COUNT(DISTINCT topic_id) FROM $bbdb->posts WHERE post_status = '0' AND poster_id = %d", $user_id ) ); 
  10. return bb_update_usermeta( $user_id, $bbdb->prefix . 'topics_replied', $topics_replied );