Say a user wishes to view a certain piece of sensitive content. How can we have the site first respond with a notice, before the content can be viewed?

Specifically, I'm looking to have the site respond with a simple NDA (Non-Disclosure Agreement) before displaying certain nodes (and even then, only to registered users, of course). But I can imagine many more uses: displaying conditions and terms related to the content, displaying an age warning for... er, more delicate content, and so on.

In my case, I need every sensitive node to display an NDA; presumably, the notice would be dismissed by some sort of "Agree" or "Proceed" link, which would then take the user to the content. After that, the node would ideally remember that the user has permission for future viewings of that specific node (i.e., doesn't need to see and agree to the notice every time).

I can imagine other sites, though, that might want to enable agreements for whole groups of content (such as a node type): view the notice once, and then have free access to any of the affected nodes.

Also, it would be ideal to have the option of allowing unimpeded view of the teaser, with the notice coming into play only when a reader tries to view the full node.

Whatever the details, does anyone have ideas for enabling this? I've found many modules or techniques to prevent access to specific nodes by user role, or password access, etc., but not to grant access after displaying a notice. There's the Legal module (http://drupal.org/project/legal) for displaying terms and conditions upon registering to become a user, but that doesn't handle viewing specific nodes.

As always, I suspect I'm missing something obvious. My kingdom for a solution!


You've listed a nebulous group of requirements that somewhat overlap with existing module projects out there. FWIW, there's also the Premium Content module which also has elements of what you're asking for.

My guess is you're not going find one that 100% matches your current and ongoing needs. So you either find one that matches the most & work on patches to that project, or you build your own. Depending on how specific your needs are one might work better than another.

If you go the "build my own" path, look at hook_node_access() & hook_node_view() (D8: hook_entity_view()) which respectively allow you step in front of node permission checks and rendering. They will be the core of your strategy to determine when to allow full access & when to send your user through a NDA confirmation workflow.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.