0

With a $user object, we can verify the user against a permission setting with the can() method. However, how can I retrieve all users who have a specific permission, including those under a group with the permission.

This needs to be generic PHP code as it's located in a service.

1 Answers1

1

I don't think there is a clean or particularly efficient way of doing this using Craft's current services.

It'd have to be something like:

1. Grab all users
2. Loop through them calling craft()->userPermissions->doesUserHavePermission()
3. If true, save user in success array.

Alternatively you could use DbCommand to query the database directly for the info you're looking for.

Brad Bell
  • 67,440
  • 6
  • 73
  • 143