WordPress filter hook

rest_private_query_vars

Fired by 5 WordPress plugins, running on 40K+ sites between them.

“Filter the allowed 'private' query vars for authorized users.”

How to use rest_private_query_vars

It's a filter: your callback receives the value, and must return the (changed) value. Add this to your theme's functions.php or a small custom plugin:

functions.php
add_filter( 'rest_private_query_vars', function( $private_query_vars ) {
	// Change $private_query_vars here.
	return $private_query_vars;
}, 10, 1 );

Argument names come from Seriously Simple Podcasting's source. Other plugins may pass different values: check the call in the plugin you're targeting below.

5 plugins that fire rest_private_query_vars

Sorted by active installs. Each entry shows where the plugin calls the hook and what it passes.

  1. Seriously Simple Podcasting icon Seriously Simple Podcasting20,000+ installs apply_filters( 'rest_private_query_vars', $wp->private_query_vars ) php/classes/rest/class-episodes-rest-controller.php:1011
  2. WordPress REST API (Version 2) icon WordPress REST API (Version 2)10,000+ installs apply_filters( 'rest_private_query_vars', $wp->private_query_vars ) lib/endpoints/class-wp-rest-posts-controller.php:724
  3. GamiPress icon GamiPress10,000+ installs apply_filters( 'rest_private_query_vars', $wp->private_query_vars ) includes/api/class-wp-rest-gamipress-posts-controller.php:291
  4. Appmaker WP icon Appmaker WP100+ installs apply_filters( 'rest_private_query_vars', $wp->private_query_vars ) lib/endpoints/appmaker/class-appmaker-wp-rest-backend-posts-controller.php:392
  5. WP Rest Api V2 Multiple PostTypes icon WP Rest Api V2 Multiple PostTypes100+ installs apply_filters( 'rest_private_query_vars', $wp->private_query_vars ) lib/endpoints/class-wp-rest-multiple-posttype-controller.php:305

Need a customisation built on this hook?

Tell us what you want to change and which plugin it's for. We'll write it, test it and send it back as a small plugin.