bbp_update_topic_last_active_time

Update the topics last active date/time (aka freshness).

Description

bbp_update_topic_last_active_time( (int) $topic_id = 0, (string) $new_time = '' ); 

Parameters (2)

0. $topic_id — Optional. (int)
Topic id
1. $new_time — Optional. (string) => ''
New time in mysql format

Usage

  1. if ( !function_exists( 'bbp_update_topic_last_active_time' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'bbpress/includes/topics/functions.php'; 
  3.  
  4. // Optional. Topic id 
  5. $topic_id = -1; 
  6.  
  7. // Optional. New time in mysql format 
  8. $new_time = ''; 
  9.  
  10. // NOTICE! Understand what this does before running. 
  11. $result = bbp_update_topic_last_active_time($topic_id, $new_time); 
  12.  

Defined (1)

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

/includes/topics/functions.php  
  1. function bbp_update_topic_last_active_time( $topic_id = 0, $new_time = '' ) { 
  2.  
  3. // If it's a reply, then get the parent (topic id) 
  4. if ( bbp_is_reply( $topic_id ) ) { 
  5. $topic_id = bbp_get_reply_topic_id( $topic_id ); 
  6. } else { 
  7. $topic_id = bbp_get_topic_id( $topic_id ); 
  8.  
  9. // Check time and use current if empty 
  10. if ( empty( $new_time ) ) { 
  11. $new_time = get_post_field( 'post_date', bbp_get_public_child_last_id( $topic_id, bbp_get_reply_post_type() ) ); 
  12.  
  13. // Update only if published 
  14. if ( !empty( $new_time ) ) { 
  15. update_post_meta( $topic_id, '_bbp_last_active_time', $new_time ); 
  16.  
  17. return apply_filters( 'bbp_update_topic_last_active_time', $new_time, $topic_id );