Created
October 23, 2016 09:11
-
-
Save websupporter/2c1e479a81842b0fa23c7406734c35b6 to your computer and use it in GitHub Desktop.
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 | |
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' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Weitere Informationen: http://websupporter.net/blog/de/so-schaltest-du-die-wordpress-rest-api-ab/