Skip to content

Instantly share code, notes, and snippets.

@gilzow
Created January 5, 2017 17:03
Show Gist options
  • Save gilzow/3b000f07aca9218a505a4827ad002154 to your computer and use it in GitHub Desktop.
Save gilzow/3b000f07aca9218a505a4827ad002154 to your computer and use it in GitHub Desktop.
Removes user endpoints from WordPress REST API
<?php
/**
* Remove user list endpoint from rest api
*/
add_filter('rest_endpoints', function($aryEndpoints){
if(isset($aryEndpoints['/wp/v2/users'])){
unset($aryEndpoints['/wp/v2/users']);
}
if(isset($aryEndpoints['/wp/v2/users/(?P<id>[\d]+)'])){
unset($aryEndpoints['/wp/v2/users/(?P<id>[\d]+)']);
}
return $aryEndpoints;
});
@miguelmayo
Copy link

Works perfect, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment