bp_activity_get( array|string $args = '' )

Retrieve an activity or activities.


Description 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 See also


Top ↑

Parameters Parameters

$args

(array|string) (Optional) See BP_Activity_Activity::get() for description.

Default value: ''


Top ↑

Return Return

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


Top ↑

Source 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.

		'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'],
		'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 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 ) );
}


Top ↑

Changelog Changelog

Changelog
Version Description
2.4.0 Introduced the $fields parameter.
1.2.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.