bbp_update_user_last_posted

Update a users last posted time, for use with post throttling.

Description

bbp_update_user_last_posted( (int) $user_id = 0, (int) $time = 0 ); 

Parameters (2)

0. $user_id — Optional. (int)
User ID to update
1. $time — Optional. (int)
Time in time() format

Usage

  1. if ( !function_exists( 'bbp_update_user_last_posted' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'bbpress/includes/users/options.php'; 
  3.  
  4. // User ID to update 
  5. $user_id = -1; 
  6.  
  7. // Time in time() format 
  8. $time = -1; 
  9.  
  10. // NOTICE! Understand what this does before running. 
  11. $result = bbp_update_user_last_posted($user_id, $time); 
  12.  

Defined (1)

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

/includes/users/options.php  
  1. function bbp_update_user_last_posted( $user_id = 0, $time = 0 ) { 
  2.  
  3. // Validate user id 
  4. $user_id = bbp_get_user_id( $user_id ); 
  5. if ( empty( $user_id ) ) 
  6. return false; 
  7.  
  8. // Set time to now if nothing is passed 
  9. if ( empty( $time ) ) 
  10. $time = time(); 
  11.  
  12. return update_user_option( $user_id, '_bbp_last_posted', $time );