bp_core_get_last_activity

Format last activity string based on time since date given.

Description

(string) bp_core_get_last_activity( (string) $last_activity_date = '', (string) $string = '' ); 

Returns (string)

$last_active A string of the form '3 years ago'.

Parameters (2)

0. $last_activity_date — Optional. (string) => ''
The date of last activity.
1. $string — Optional. (string) => ''
A sprintf()-able statement of the form active %s..

Usage

  1. if ( !function_exists( 'bp_core_get_last_activity' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'buddypress/bp-core/bp-core-functions.php'; 
  3.  
  4. // The date of last activity. 
  5. $last_activity_date = ''; 
  6.  
  7. // A sprintf()-able statement of the form 'active %s'. 
  8. $string = ''; 
  9.  
  10. // NOTICE! Understand what this does before running. 
  11. $result = bp_core_get_last_activity($last_activity_date, $string); 
  12.  

Defined (1)

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

/bp-core/bp-core-functions.php  
  1. function bp_core_get_last_activity( $last_activity_date = '', $string = '' ) { 
  2.  
  3. // Setup a default string if none was passed. 
  4. $string = empty( $string ) 
  5. ? '%s' // Gettext placeholder. 
  6. : $string; 
  7.  
  8. // Use the string if a last activity date was passed. 
  9. $last_active = empty( $last_activity_date ) 
  10. ? __( 'Not recently active', buddypress ) 
  11. : sprintf( $string, bp_core_time_since( $last_activity_date ) ); 
  12.  
  13. /** 
  14. * Filters last activity string based on time since date given. 
  15. * @since 1.2.0 
  16. * @param string $last_active Last activity string based on time since date given. 
  17. * @param string $last_activity_date The date of last activity. 
  18. * @param string $string A sprintf()-able statement of the form 'active %s'. 
  19. */ 
  20. return apply_filters( 'bp_core_get_last_activity', $last_active, $last_activity_date, $string );