Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Allow WordPress REST API Requests While Restricted Site Access is Active
* Plugin Name: Unrestrict REST API
* Plugin URI:
* Description: Allows REST API requests while Restricted Site Access is enabled.
* Version: 0.1.0
* Author: Philip Newcomer
* Author URI:
* Filter Restricted Site Access to allow REST API requests.
* @param bool $is_restricted Whether access is restricted.
* @param object $wp The WordPress object.
* @return bool Whether access should be restricted.
function pn_unrestrict_rest_api( $is_restricted, $wp ) {
if ( ! empty( $wp->query_vars['rest_route'] ) ) {
return false;
return $is_restricted;
add_filter( 'restricted_site_access_is_restricted', 'pn_unrestrict_rest_api', 10, 2 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.