bp_activity_get_current_context()

Gets the current activity context.

Description

The "context" is the current view type, corresponding roughly to the current component. Use this context to determine which activity actions should be whitelisted for the filter dropdown.

Return

(string) Activity context. 'member', 'member_groups', 'group', 'activity'.

Source

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

function bp_activity_get_current_context() {
	// On member pages, default to 'member', unless this is a user's Groups activity.
	if ( bp_is_user() ) {
		if ( bp_is_active( 'groups' ) && bp_is_current_action( bp_get_groups_slug() ) ) {
			$context = 'member_groups';
		} else {
			$context = 'member';
		}

	// On individual group pages, default to 'group'.
	} elseif ( bp_is_active( 'groups' ) && bp_is_group() ) {
		$context = 'group';

	// 'activity' everywhere else.
	} else {
		$context = 'activity';
	}

	return $context;
}

Changelog

Changelog
Version Description
BuddyPress 2.8.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.