bp_activity_get_user_favorites

Get a users favorite activity stream items.

Description

(array) bp_activity_get_user_favorites( (int) $user_id = 0 ); 

Returns (array)

IDs of the user's favorite activity items.

Parameters (1)

0. $user_id — Optional. (int)
ID of the user whose favorites are being queried.

Usage

  1. if ( !function_exists( 'bp_activity_get_user_favorites' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'buddypress/bp-activity/bp-activity-functions.php'; 
  3.  
  4. // ID of the user whose favorites are being queried. 
  5. $user_id = -1; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = bp_activity_get_user_favorites($user_id); 
  9.  

Defined (1)

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

/bp-activity/bp-activity-functions.php  
  1. function bp_activity_get_user_favorites( $user_id = 0 ) { 
  2.  
  3. // Fallback to logged in user if no user_id is passed. 
  4. if ( empty( $user_id ) ) { 
  5. $user_id = bp_displayed_user_id(); 
  6.  
  7. // Get favorites for user. 
  8. $favs = bp_get_user_meta( $user_id, 'bp_favorite_activities', true ); 
  9.  
  10. /** 
  11. * Filters the favorited activity items for a specified user. 
  12. * @since 1.2.0 
  13. * @param array $favs Array of user's favorited activity items. 
  14. */