bb_topic_set_last_post

The BuddyPress bb topic set last post function.

Description

bb_topic_set_last_post( $topic_id ); 

Parameters (1)

0. $topic_id
The topic id.

Usage

  1. if ( !function_exists( 'bb_topic_set_last_post' ) ) { 
  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_topic_set_last_post($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_topic_set_last_post( $topic_id ) { 
  2. global $bbdb; 
  3. $topic_id = (int) $topic_id; 
  4. $old_post = $bbdb->get_row( $bbdb->prepare( 
  5. "SELECT post_id, poster_id, post_time FROM $bbdb->posts WHERE topic_id = %d AND post_status = 0 ORDER BY post_time DESC LIMIT 1", $topic_id 
  6. ) ); 
  7. $old_poster = bb_get_user( $old_post->poster_id ); 
  8. wp_cache_delete( $topic_id, 'bb_topic' ); 
  9. return $bbdb->update( $bbdb->topics, array( 'topic_time' => $old_post->post_time, 'topic_last_poster' => $old_post->poster_id, 'topic_last_poster_name' => $old_poster->login_name, 'topic_last_post_id' => $old_post->post_id ), compact( 'topic_id' ) );