bp_get_last_activity

Get the "active [x days ago]" string for a user.

Description

(string) bp_get_last_activity( (int) $user_id = 0 ); 

Returns (string)

Parameters (1)

0. $user_id — Optional. (int)
ID of the user. Default: displayed user ID.

Usage

  1. if ( !function_exists( 'bp_get_last_activity' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'buddypress/bp-members/bp-members-template.php'; 
  3.  
  4. // ID of the user. Default: displayed user ID. 
  5. $user_id = -1; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = bp_get_last_activity($user_id); 
  9.  

Defined (1)

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

/bp-members/bp-members-template.php  
  1. function bp_get_last_activity( $user_id = 0 ) { 
  2.  
  3. if ( empty( $user_id ) ) 
  4. $user_id = bp_displayed_user_id(); 
  5.  
  6. $last_activity = bp_core_get_last_activity( bp_get_user_last_activity( $user_id ), __('active %s', buddypress) ); 
  7.  
  8. /** 
  9. * Filters the 'active [x days ago]' string for a user. 
  10. * @since 1.5.0 
  11. * @since 2.6.0 Added the `$user_id` parameter. 
  12. * @param string $value Formatted 'active [x days ago]' string. 
  13. * @param int $user_id ID of the user. 
  14. */ 
  15. return apply_filters( 'bp_get_last_activity', $last_activity, $user_id );