bp_activity_filter_favorites_scope

Set up activity arguments for use with the 'favorites' scope.

Description

(array) bp_activity_filter_favorites_scope( (array) $retval = array(), (array) $filter = array() ); 

Returns (array)

$retval

Parameters (2)

0. $retval — Optional. (array) => array()
Empty array by default.
1. $filter — Optional. (array) => array()
Current activity arguments.

Usage

  1. if ( !function_exists( 'bp_activity_filter_favorites_scope' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'buddypress/bp-activity/bp-activity-filters.php'; 
  3.  
  4. // Empty array by default. 
  5. $retval = array(); 
  6.  
  7. // Current activity arguments. 
  8. $filter = array(); 
  9.  
  10. // NOTICE! Understand what this does before running. 
  11. $result = bp_activity_filter_favorites_scope($retval, $filter); 
  12.  

Defined (1)

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

/bp-activity/bp-activity-filters.php  
  1. function bp_activity_filter_favorites_scope( $retval = array(), $filter = array() ) { 
  2.  
  3. // Determine the user_id. 
  4. if ( ! empty( $filter['user_id'] ) ) { 
  5. $user_id = $filter['user_id']; 
  6. } else { 
  7. $user_id = bp_displayed_user_id() 
  8.  
  9. // Determine the favorites. 
  10. $favs = bp_activity_get_user_favorites( $user_id ); 
  11. if ( empty( $favs ) ) { 
  12. $favs = array( 0 ); 
  13.  
  14. // Should we show all items regardless of sitewide visibility? 
  15. $show_hidden = array(); 
  16. if ( ! empty( $user_id ) && ( $user_id !== bp_loggedin_user_id() ) ) { 
  17. $show_hidden = array( 
  18. 'column' => 'hide_sitewide',  
  19. 'value' => 0 
  20. ); 
  21.  
  22. $retval = array( 
  23. 'relation' => 'AND',  
  24. array( 
  25. 'column' => 'id',  
  26. 'compare' => 'IN',  
  27. 'value' => (array) $favs 
  28. ),  
  29. $show_hidden,  
  30.  
  31. // Overrides. 
  32. 'override' => array( 
  33. 'display_comments' => true,  
  34. 'filter' => array( 'user_id' => 0 ),  
  35. 'show_hidden' => true 
  36. ),  
  37. ); 
  38.  
  39. return $retval;