bp_activity_get

Retrieve an activity or activities.

Description

(array) bp_activity_get( (string) $args = '' ); 

The bp_activity_get() function shares all arguments with BP_Activity_Activity::get(). The following is a list of bp_activity_get() parameters that have different default values from BP_Activity_Activity::get() (value in parentheses is the default for the bp_activity_get()). - per_page (false)

Returns (array)

$activity See BP_Activity_Activity::get() for description.

Parameters (1)

0. $args — Optional. (string) => ''
See BP_Activity_Activity::get() for description.

Usage

  1. if ( !function_exists( 'bp_activity_get' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'buddypress/bp-activity/bp-activity-functions.php'; 
  3.  
  4. // See BP_Activity_Activity::get() for description. 
  5. $args = ''; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = bp_activity_get($args); 
  9.  

Defined (1)

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

/bp-activity/bp-activity-functions.php  
  1. function bp_activity_get( $args = '' ) { 
  2.  
  3. $r = bp_parse_args( $args, array( 
  4. 'max' => false, // Maximum number of results to return. 
  5. 'fields' => 'all',  
  6. 'page' => 1, // Page 1 without a per_page will result in no pagination. 
  7. 'per_page' => false, // results per page 
  8. 'sort' => 'DESC', // sort ASC or DESC 
  9. 'display_comments' => false, // False for no comments. 'stream' for within stream display, 'threaded' for below each activity item. 
  10.  
  11. 'search_terms' => false, // Pass search terms as a string 
  12. 'meta_query' => false, // Filter by activity meta. See WP_Meta_Query for format 
  13. 'date_query' => false, // Filter by date. See first parameter of WP_Date_Query for format. 
  14. 'filter_query' => false,  
  15. 'show_hidden' => false, // Show activity items that are hidden site-wide? 
  16. 'exclude' => false, // Comma-separated list of activity IDs to exclude. 
  17. 'in' => false, // Comma-separated list or array of activity IDs to which you 
  18. // want to limit the query. 
  19. 'spam' => 'ham_only', // 'ham_only' (default), 'spam_only' or 'all'. 
  20. 'update_meta_cache' => true,  
  21. 'count_total' => false,  
  22. 'scope' => false,  
  23.  
  24. /** 
  25. * Pass filters as an array -- all filter items can be multiple values comma separated: 
  26. * array( 
  27. * 'user_id' => false, // User ID to filter on. 
  28. * 'object' => false, // Object to filter on e.g. groups, profile, status, friends. 
  29. * 'action' => false, // Action to filter on e.g. activity_update, profile_updated. 
  30. * 'primary_id' => false, // Object ID to filter on e.g. a group_id or forum_id or blog_id etc. 
  31. * 'secondary_id' => false, // Secondary object ID to filter on e.g. a post_id. 
  32. * ); 
  33. */ 
  34. 'filter' => array() 
  35. ), 'activity_get' ); 
  36.  
  37. $activity = BP_Activity_Activity::get( array( 
  38. 'page' => $r['page'],  
  39. 'per_page' => $r['per_page'],  
  40. 'max' => $r['max'],  
  41. 'sort' => $r['sort'],  
  42. 'search_terms' => $r['search_terms'],  
  43. 'meta_query' => $r['meta_query'],  
  44. 'date_query' => $r['date_query'],  
  45. 'filter_query' => $r['filter_query'],  
  46. 'filter' => $r['filter'],  
  47. 'scope' => $r['scope'],  
  48. 'display_comments' => $r['display_comments'],  
  49. 'show_hidden' => $r['show_hidden'],  
  50. 'exclude' => $r['exclude'],  
  51. 'in' => $r['in'],  
  52. 'spam' => $r['spam'],  
  53. 'update_meta_cache' => $r['update_meta_cache'],  
  54. 'count_total' => $r['count_total'],  
  55. 'fields' => $r['fields'],  
  56. ) ); 
  57.  
  58. /** 
  59. * Filters the requested activity item(s). 
  60. * @since 1.2.0 
  61. * @param BP_Activity_Activity $activity Requested activity object. 
  62. * @param array $r Arguments used for the activity query. 
  63. */ 
  64. return apply_filters_ref_array( 'bp_activity_get', array( &$activity, &$r ) );