Site icon Hip-Hop Website Design and Development

REST API – Allow /users endpoint depending on a custom capability

I am in a situation where I have to list users for a frontend app dropdown via REST API. By default, WP will not allow listing of users without list_users cap. My plugin has its own custom capability which is added from the options page. So I want to be able to allow selected subscribers to get a list of users (reduced information). I don’t see any filters on the permission function to manipulate the check.

Is it possible in any other way without creating a separate endpoint? I don’t want to add the list_users cap to subscribers for obvious reasons.