Skip to content
Docs
Get RestroPress

Filter

rpress_api_public_query_modes

Updated
On this page

Filters the API query modes that can be accessed without an API key.

Runs when the API checks whether a request is public. The default list contains only products. Requests for a listed query mode skip authentication unless a token is sent, so add modes with care because their data becomes readable by anyone.

Parameters#

ParameterTypeDescription
$public_modesarrayQuery mode slugs that do not require authentication.

Return value#

array. The list of public query mode slugs.

Example#

function my_api_public_query_modes( $public_modes ) {
	$public_modes[] = 'info';
	return $public_modes;
}
add_filter( 'rpress_api_public_query_modes', 'my_api_public_query_modes' );

Notes#

Anything added here is exposed without authentication.

Source#

Applied in:

  • includes/api/class-rpress-api.php (line 292), in RPRESS_API::is_public_query()

See also#

Was this page helpful?