Disable part of endpoints wordpress api

I try to disable some parts of the API :

  • display list of users
  • display detail of users

But i want to keep the api to create and update users.

I did this :

add_filter( 'rest_endpoints', 'disable_custom_rest_endpoints' ); function disable_custom_rest_endpoints( $  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; } 

My problem : this delete the possibility to update or create user as well

Is there another way to do it ?

Thanks