Last active
May 19, 2018 16:57
-
-
Save alanef/81afde004167756ad053b8ce559a71de to your computer and use it in GitHub Desktop.
Disalow user resi api all users
This file contains hidden or 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
| add_action( 'rest_authentication_errors', 'disallow_user_rest_access_to_users' ); | |
| function disallow_user_rest_access_to_users( $access ) { | |
| if ( ( isset( $_REQUEST['rest_route'] ) && ( preg_match( '/users/', $_REQUEST['rest_route'] ) !== 0 ) ) { | |
| return new WP_Error( 'rest_cannot_access', esc_html__( 'No Access to User endpoint REST API.', 'mytext' ), array( 'status' => rest_authorization_required_code() ) ); | |
| } | |
| return $access; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment