Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save evemilano/814ac290e51c558a89abd1194b3bb680 to your computer and use it in GitHub Desktop.
Save evemilano/814ac290e51c558a89abd1194b3bb680 to your computer and use it in GitHub Desktop.
Disable the WordPress REST API
add_filter( 'rest_authentication_errors', function( $result ) {
if ( ! empty( $result ) ) {
return $result;
}
if ( ! is_user_logged_in() ) {
return new WP_Error( 'rest_not_logged_in', 'You are not currently logged in.', array( 'status' => 401 ) );
}
return $result;
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment