check the requesting url
That filter is definitely not the one you are looking for. That filter fires before returning the result of WP_REST_Request::from_url() which appears to be a factory method that is only used internally to handle embeds. A better option is to return a WP_Error instance on the rest_pre_dispatch filter. Some caveats: As mentioned by @milo, the … Read more