bp_get_activity_latest_update

Return the activity latest update link.

Description

(string|bool) bp_get_activity_latest_update( (int) $user_id = 0 ); 

Returns (string|bool)

$latest_update The activity latest update link. False on failure.

Parameters (1)

0. $user_id — Optional. (int)
If empty, will fall back on displayed user.

Usage

  1. if ( !function_exists( 'bp_get_activity_latest_update' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'buddypress/bp-activity/bp-activity-template.php'; 
  3.  
  4. // If empty, will fall back on displayed user. 
  5. $user_id = -1; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = bp_get_activity_latest_update($user_id); 
  9.  

Defined (1)

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

/bp-activity/bp-activity-template.php  
  1. function bp_get_activity_latest_update( $user_id = 0 ) { 
  2.  
  3. if ( empty( $user_id ) ) { 
  4. $user_id = bp_displayed_user_id(); 
  5.  
  6. if ( bp_is_user_inactive( $user_id ) ) { 
  7. return false; 
  8.  
  9. if ( !$update = bp_get_user_meta( $user_id, 'bp_latest_update', true ) ) { 
  10. return false; 
  11.  
  12. /** 
  13. * Filters the latest update excerpt. 
  14. * @since 1.2.10 
  15. * @since 2.6.0 Added the `$user_id` parameter. 
  16. * @param string $value The excerpt for the latest update. 
  17. * @param int $user_id ID of the queried user. 
  18. */ 
  19. $latest_update = apply_filters( 'bp_get_activity_latest_update_excerpt', trim( strip_tags( bp_create_excerpt( $update['content'], bp_activity_get_excerpt_length() ) ) ), $user_id ); 
  20.  
  21. $latest_update = sprintf( 
  22. '%s <a href="%s">%s</a>',  
  23. $latest_update,  
  24. esc_url_raw( bp_activity_get_permalink( $update['id'] ) ),  
  25. esc_attr__( 'View', buddypress ) 
  26. ); 
  27.  
  28. /** 
  29. * Filters the latest update excerpt with view link appended to the end. 
  30. * @since 1.2.0 
  31. * @since 2.6.0 Added the `$user_id` parameter. 
  32. * @param string $latest_update The latest update with "view" link appended to it. 
  33. * @param int $user_id ID of the queried user. 
  34. */ 
  35. return apply_filters( 'bp_get_activity_latest_update', $latest_update, $user_id );