Skip to main content
100%

Gist c74189a31788f3b07d62c559357ffeef

✓ Published0🌍 Public
KKopylovVitalik
Last edited Oct 26, 2020
Created on Oct 26, 2020

This example shows a WordPress code snippet that restricts access to the WordPress REST API. It uses the `rest_authentication_errors` filter hook to deny requests from unauthenticated users, returning a `WP_Error` with a 401 status unless the request URI contains "contact-form-7". The code checks the global `$wp_json_basic_auth_error` variable and incorporates a custom authentication check using `is_user_logged_in()` and `strpos()` on the server request URI.

AI-generated description

Similar vizzes