bp_friends_filter_activity_scope

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

Description

(array) bp_friends_filter_activity_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_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_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_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 friends of user. 
  10. $friends = friends_get_friend_user_ids( $user_id ); 
  11. if ( empty( $friends ) ) { 
  12. $friends = array( 0 ); 
  13.  
  14. $retval = array( 
  15. 'relation' => 'AND',  
  16. array( 
  17. 'column' => 'user_id',  
  18. 'compare' => 'IN',  
  19. 'value' => (array) $friends 
  20. ),  
  21.  
  22. // We should only be able to view sitewide activity content for friends. 
  23. array( 
  24. 'column' => 'hide_sitewide',  
  25. 'value' => 0 
  26. ),  
  27.  
  28. // Overrides. 
  29. 'override' => array( 
  30. 'filter' => array( 'user_id' => 0 ),  
  31. 'show_hidden' => true 
  32. ),  
  33. ); 
  34.  
  35. return $retval;