Last active
October 13, 2023 16:24
-
-
Save bobbydank/f896ddc4caef76d87181940a7db8ab38 to your computer and use it in GitHub Desktop.
disables wordpress rest api
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_filter( | |
'rest_authentication_errors', | |
function ($access) { | |
return new WP_Error( | |
'rest_disabled', | |
__("The Wordpress REST API has been disabled."), | |
array( | |
'status' => rest_authorization_required_code(), | |
) | |
); | |
} | |
); | |
// if you need rest api for Elmentor or other logged in processes: | |
if (!is_user_logged_in()) { | |
add_filter( | |
'rest_authentication_errors', | |
function ($access) { | |
return new WP_Error( | |
'rest_disabled', | |
__("The Wordpress REST API has been disabled."), | |
array( | |
'status' => rest_authorization_required_code(), | |
) | |
); | |
} | |
); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment