Skip to content

Instantly share code, notes, and snippets.

@alanef
Last active May 19, 2018 16:57
Show Gist options
  • Select an option

  • Save alanef/81afde004167756ad053b8ce559a71de to your computer and use it in GitHub Desktop.

Select an option

Save alanef/81afde004167756ad053b8ce559a71de to your computer and use it in GitHub Desktop.
Disalow user resi api all users
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