Skip to content

Instantly share code, notes, and snippets.

@websupporter
Created October 23, 2016 09:11
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 websupporter/2c1e479a81842b0fa23c7406734c35b6 to your computer and use it in GitHub Desktop.
Save websupporter/2c1e479a81842b0fa23c7406734c35b6 to your computer and use it in GitHub Desktop.
<?php
function only_allow_logged_in_rest_access( $access ) {
if( ! is_user_logged_in() ) {
return new WP_Error( 'rest_cannot_access', 'Du kannst nur eingeloggt die REST API nutzen.', array( 'status' => rest_authorization_required_code() ) );
}
return $access;
}
add_filter( 'rest_authentication_errors', 'only_allow_logged_in_rest_access' );
@websupporter
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment