bp_activity_get( array|string $args = '' )

Retrieve an activity or activities.

Description

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)

See also

Parameters

$args

(Optional) See BP_Activity_Activity::get() for description.

Default value: ''

Return

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

Source

File: bp-activity/bp-activity-functions.php

function bp_activity_get( $args = '' ) {

	$r = bp_parse_args( $args, array(
		'max'               => false,        // Maximum number of results to return.
		'fields'            => 'all',
		'page'              => 1,            // Page 1 without a per_page will result in no pagination.
		'per_page'          => false,        // results per page
		'sort'              => 'DESC',       // sort ASC or DESC
		'display_comments'  => false,        // False for no comments. 'stream' for within stream display, 'threaded' for below each activity item.

		'privacy'           => false,        // Privacy of activity
		'search_terms'      => false,        // Pass search terms as a string
		'meta_query'        => false,        // Filter by activity meta. See WP_Meta_Query for format
		'date_query'        => false,        // Filter by date. See first parameter of WP_Date_Query for format.
		'filter_query'      => false,
		'show_hidden'       => false,        // Show activity items that are hidden site-wide?
		'exclude'           => false,        // Comma-separated list of activity IDs to exclude.
		'in'                => false,        // Comma-separated list or array of activity IDs to which you
		                                     // want to limit the query.
		'spam'              => 'ham_only',   // 'ham_only' (default), 'spam_only' or 'all'.
		'update_meta_cache' => true,
		'count_total'       => false,
		'scope'             => false,

		/**
		 * Pass filters as an array -- all filter items can be multiple values comma separated:
		 * array(
		 *     'user_id'      => false, // User ID to filter on.
		 *     'object'       => false, // Object to filter on e.g. groups, profile, status, friends.
		 *     'action'       => false, // Action to filter on e.g. activity_update, profile_updated.
		 *     'primary_id'   => false, // Object ID to filter on e.g. a group_id or blog_id etc.
		 *     'secondary_id' => false, // Secondary object ID to filter on e.g. a post_id.
		 * );
		 */
		'filter' => array()
	), 'activity_get' );

	$activity = BP_Activity_Activity::get( array(
		'page'              => $r['page'],
		'per_page'          => $r['per_page'],
		'max'               => $r['max'],
		'sort'              => $r['sort'],
		'privacy'           => $r['privacy'],
		'search_terms'      => $r['search_terms'],
		'meta_query'        => $r['meta_query'],
		'date_query'        => $r['date_query'],
		'filter_query'      => $r['filter_query'],
		'filter'            => $r['filter'],
		'scope'             => $r['scope'],
		'display_comments'  => $r['display_comments'],
		'show_hidden'       => $r['show_hidden'],
		'exclude'           => $r['exclude'],
		'in'                => $r['in'],
		'spam'              => $r['spam'],
		'update_meta_cache' => $r['update_meta_cache'],
		'count_total'       => $r['count_total'],
		'fields'            => $r['fields'],
	) );

	/**
	 * Filters the requested activity item(s).
	 *
	 * @since BuddyPress 1.2.0
	 *
	 * @param BP_Activity_Activity $activity Requested activity object.
	 * @param array                $r        Arguments used for the activity query.
	 */
	return apply_filters_ref_array( 'bp_activity_get', array( &$activity, &$r ) );
}

Changelog

Changelog
Version Description
BuddyPress 1.2.0 Introduced.

Questions?

We're always happy to help with code or other questions you might have! Search our developer docs, contact support, or connect with our sales team.