bp_friends_filter_activity_just_me_scope

Set up activity arguments for use with the 'just-me' scope.

Description

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

For details on the syntax, see .

Returns (array)

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_friends_filter_activity_just_me_scope' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'buddypress/bp-friends/bp-friends-activity.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_friends_filter_activity_just_me_scope($retval, $filter); 
  12.  

Defined (1)

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

/bp-friends/bp-friends-activity.php  
  1. function bp_friends_filter_activity_just_me_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. // Get the requested action. 
  10. $action = $filter['filter']['action']; 
  11.  
  12. // Make sure actions are listed in an array. 
  13. if ( ! is_array( $action ) ) { 
  14. $action = explode( ', ', $filter['filter']['action'] ); 
  15.  
  16. $action = array_flip( array_filter( $action ) ); 
  17.  
  18. /** 
  19. * If filtering activities for something other than the friendship_created 
  20. * action return without changing anything 
  21. */ 
  22. if ( ! empty( $action ) && ! isset( $action['friendship_created'] ) ) { 
  23. return $retval; 
  24.  
  25. // Juggle existing override value. 
  26. $override = array(); 
  27. if ( ! empty( $retval['override'] ) ) { 
  28. $override = $retval['override']; 
  29. unset( $retval['override'] ); 
  30.  
  31. /** 
  32. * Else make sure to get the friendship_created action, the user is involved in 
  33. * - user initiated the friendship 
  34. * - user has been requested a friendship 
  35. */ 
  36. $retval = array( 
  37. 'relation' => 'OR',  
  38. $retval,  
  39. array( 
  40. 'relation' => 'AND',  
  41. array( 
  42. 'column' => 'component',  
  43. 'value' => 'friends',  
  44. ),  
  45. array( 
  46. 'column' => 'secondary_item_id',  
  47. 'value' => $user_id,  
  48. ),  
  49. ); 
  50.  
  51. // Juggle back override value. 
  52. if ( ! empty( $override ) ) { 
  53. $retval['override'] = $override; 
  54.  
  55. return $retval;