Skip to content

Commit

Permalink
Merge pull request #11 from eighteen73/develop
Browse files Browse the repository at this point in the history
Disable the /wp-json/wp/v2/users endpoint only when not admin
  • Loading branch information
brettsmason authored Jun 4, 2024
2 parents 691e645 + 3ecdab3 commit 16dcd35
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions includes/classes/Security/DisableAPI.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,13 @@ public function setup() {
* @return array
*/
public function disable_users( array $endpoints ): array {
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]+)'] );
if ( ! is_user_logged_in() && ! is_admin() ) {
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;
}
Expand Down

0 comments on commit 16dcd35

Please sign in to comment.