Guest User

Untitled

a guest
May 24th, 2018
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.43 KB | None | 0 0
  1. add_action( 'rest_authentication_errors', 'disallow_user_rest_access_to_users' );
  2. function disallow_user_rest_access_to_users( $access ) {
  3. if ( ( isset( $_REQUEST['rest_route'] ) && ( preg_match( '/users/', $_REQUEST['rest_route'] ) !== 0 ) ) {
  4. return new WP_Error( 'rest_cannot_access', esc_html__( 'No Access to User endpoint REST API.', 'mytext' ), array( 'status' => rest_authorization_required_code() ) );
  5. }
  6. return $access;
  7. }
Add Comment
Please, Sign In to add comment