BP_REST_Document_Endpoint::bp_rest_document_default_scope( string $scope, array $args )
Get default scope for the document.
Description
Parameters
- $scope
-
(string) (Required) Default scope.
- $args
-
(array) (Required) Array of document argument.
Return
(string)
Source
File: bp-document/classes/class-bp-rest-document-endpoint.php
public function bp_rest_document_default_scope( $scope, $args ) { $new_scope = array(); if ( ( 'all' === $scope || empty( $scope ) ) && ( empty( $args['group_id'] ) && empty( $args['user_id'] ) ) ) { $new_scope[] = 'public'; if ( is_user_logged_in() ) { $new_scope[] = 'personal'; if ( bp_is_active( 'friends' ) ) { $new_scope[] = 'friends'; } } if ( bp_is_active( 'groups' ) ) { $new_scope[] = 'groups'; } } elseif ( ! empty( $args['user_id'] ) && ( 'all' === $scope || empty( $scope ) ) ) { $new_scope[] = 'personal'; } elseif ( bp_is_active( 'groups' ) && ! empty( $args['group_id'] ) && ( 'all' === $scope || empty( $scope ) ) ) { $new_scope[] = 'groups'; } $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_document_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.