BP_REST_Activity_Endpoint::bp_rest_activity_default_scope( string $scope = 'all', int $user_id, int $group_id )

Get default scope for the activity – from: bp_activity_default_scope();

Description

Parameters

$scope

(string) (Optional) Default scope.

Default value: 'all'

$user_id

(int) (Required) User ID.

$group_id

(int) (Required) Group ID.

Return

(string)

Source

File: bp-activity/classes/class-bp-rest-activity-endpoint.php

	public function bp_rest_activity_default_scope( $scope = 'all', $user_id = 0, $group_id = 0 ) {
		$new_scope = array();

		if ( bp_loggedin_user_id() && ( 'all' === $scope || empty( $scope ) ) ) {

			$new_scope[] = 'public';

			if ( bp_is_active( 'group' ) && ! empty( $group_id ) ) {
				$new_scope[] = 'groups';
			} else {
				$new_scope[] = 'just-me';

				if ( empty( $user_id ) ) {
					$new_scope[] = 'public';
				}

				if ( function_exists( 'bp_activity_do_mentions' ) && bp_activity_do_mentions() ) {
					$new_scope[] = 'mentions';
				}

				if ( bp_is_active( 'friends' ) ) {
					$new_scope[] = 'friends';
				}

				if ( bp_is_active( 'groups' ) ) {
					$new_scope[] = 'groups';
				}

				if ( function_exists( 'bp_is_activity_follow_active' ) && bp_is_activity_follow_active() ) {
					$new_scope[] = 'following';
				}

				if ( bp_is_single_activity() && bp_is_active( 'media' ) ) {
					$new_scope[] = 'media';
					$new_scope[] = 'document';
				}
			}
		} elseif ( ! bp_loggedin_user_id() && ( 'all' === $scope || empty( $scope ) ) ) {
			$new_scope[] = 'public';
		}

		$new_scope = array_unique( $new_scope );

		if ( empty( $new_scope ) ) {
			$new_scope = (array) $scope;
		}

		/**
		 * Filter to update default scope.
		 */
		$new_scope = apply_filters( 'bp_rest_activity_default_scope', $new_scope );

		return implode( ',', $new_scope );

	}

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.