-
Notifications
You must be signed in to change notification settings - Fork 173
9.5. Filtering users by role
jeff-h edited this page Oct 17, 2016
·
2 revisions
- Subclass
DataProviderEntity - Implement
dataProviderClassName()in your resource entity class and point it to the class from step 1 as per Assigning a different data provider - Override method
queryForListFilter() - In
queryforListFilter()add a special query tag and add the requested roles to the query metadata - In your
custom.moduleimplementhook_query_alter() - In
hook_query_alter(), retrieve the roles from the query metadata, and use them in a join with theUSERS_ROLEStable like this:
$query->leftJoin('users_roles', 'ur', 'users.uid = ur.uid');
$query->condition('ur.rid', $rids, 'IN');In this example URL, the custom resource endpoint is myusers.
http://example.com/api/v1.0/myusers?filter[roles]=1
https://github.com/RESTful-Drupal/restful/issues/811#issuecomment-214528417