Skip to content

Instantly share code, notes, and snippets.

@MwieMarin
Created November 19, 2019 18:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save MwieMarin/950d0d6a2e3d439700fdac14d9f71e22 to your computer and use it in GitHub Desktop.
Save MwieMarin/950d0d6a2e3d439700fdac14d9f71e22 to your computer and use it in GitHub Desktop.
WordPress: Disable REST API User Enumeration
<?php
add_filter( 'rest_endpoints', function( $endpoints ){
if ( isset( $endpoints['/wp/v2/users'] ) ) {
unset( $endpoints['/wp/v2/users'] );
}
if ( isset( $endpoints['/wp/v2/users/(?P<id>[\d]+)'] ) ) {
unset( $endpoints['/wp/v2/users/(?P<id>[\d]+)'] );
}
return $endpoints;
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment