bp_rest_restrict_wp_attachment_query( array $args )

Update attachment rest query argument to hide media/document from media endpoints.

Description

  • Privacy security.

Parameters

$args

(array) (Required) WP_Query parsed arguments.

Return

(array)

Source

File: bp-core/bp-core-filters.php

function bp_rest_restrict_wp_attachment_query( $args ) {
	$meta_query = ( array_key_exists( 'meta_query', $args ) ? $args['meta_query'] : array() );

	// phpcs:ignore WordPress.DB.SlowDBQuery.slow_db_query_meta_query
	$args['meta_query'] = array(
		array(
			'key'     => 'bp_media_upload',
			'compare' => 'NOT EXISTS',
		),
		array(
			'key'     => 'bp_document_upload',
			'compare' => 'NOT EXISTS',
		),
	);

	if ( ! empty( $meta_query ) ) {
		$args['meta_query'][] = $meta_query;
	}

	if ( count( $args['meta_query'] ) > 1 ) {
		$args['meta_query']['relation'] = 'AND';
	}

	return $args;
}

Changelog

Changelog
Version Description
BuddyBoss 1.5.5 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.