Add AccessControl Layer for WordPress #12
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR is in addition to UseDataKit/SDK#40 and tries to address #11.
It adds a
WordPressAccessController
which currently checks if the users is a admin. If they are, they have all the power; otherwise it falls back to the defaultReadOnlyAccessController
behaviour.So this PR might need some (future) work, but it is already very customisable through the
datakit/acl/can
filter. This filter returns the current accessibility (true or false), in addition to theCapability
( which contains the context to make decisions) and the currentWP_User
.The
ViewController
and the short code now both check if the current user can see the dataview, and act accordingly.@zackkatz I'm hoping you can fill in the blanks for me as it comes to user roles, or if this might be enough for a first iteration. We can change default behaviour later on; while maintaining the hooks for people to overwrite the logic.