Change grant based on the value of a field

Created on 4 July 2016, over 9 years ago
Updated 25 September 2025, 11 days ago

I'd like to be able to add or remove the "View" grant for anonymous users based on the value of a field on node.

Specific use case - I've got a client who gives grants to organizations. Part of their requirements when giving a grant is to receive annual reports on what the organization has done with the grant. The organization gets to choose whether any given report is to be "public" (anonymous users) or "private" (board members & the user who uploaded the report).

The goal is to make everything "private" by default, but to automatically add "View" access for anonymous users if "public" is selected in the node edit form.

The default "private" status works as expected. All I need to do now is figure out how to programmatically add "View" when "public" is selected.

I've spent a few hours Googling and not making much headway. Is there a simple way to do this that I have somehow just missed? Assuming I need to do this in code, is there a recommended way to do this?

I'm still learning the ins and outs of building modules. This initially seemed like it should be pretty straight forward, but there seem to be a number of different hooks that all seem equally plausible to use for this. I can't make anything I've tried so far work - any help / suggestions would be much appreciated.

Thanks!
Dan

πŸ’¬ Support request
Status

Postponed: needs info

Version

1.4

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States dang42

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

No activities found.

Production build 0.71.5 2024