Posted: June 30, 2020 at 2:33 pm
Trying to find a way to allow users with several capabilities to access with “and” or “or” when multiple roles or capabilities are listed in the ticket capability requirement.
How should I interpret a role into a “capabilities” so I can effect these sorts of cases?
Possibly something similar to this:
A role is simply a set of capabilities. It’s an easy way to group them together but it should not be used to define what you have access to.
For example, I can give you a user account on my site and set it to have the Administrator role, but I can then remove the capabilities on that account to match say a subscriber. Your account should (and if caps are used correctly will) only have access to exactly the same as what a user with a subscriber role would.
Multiple capabilities are not officially supported with the current EE ticket capability check but it is possible to hook in and add your own processing to this.
An example of doing this can be found here: https://gist.github.com/Pebblo/4f035d70b160c86f03442675e3d44e7f
That function allows you to set multiple capabilities separated by a comma and then loops over them to check if the current user has any of those capabilites. So you’ll need to alter that function to check they have each of the caps you set and return a ‘true’ value if they do, otherwise return false as they don’t have access.