We use a D7 site to market and sell products B2B. We have a special client that only wants to see a small selection of products when logged in. I can of course give them a special role and allow them permission to view content that others cannot see. But when it comes to hiding ALL the other products on the site, I'm not sure how to think... it means giving them more restrictions when logged in with a special user role.

Normally you get more access when logged in and given a special role, compared to not being logged in at all. But in this case I need to do the opposite.

Any ideas?

  • Play around with views and permissions. I don't know what exactly you got going on for the best direction, but you could create a dashboard view that limits these products based on which user is logged in. Instead of a role, maybe create an attribute/field on their profile you could use to filter the products. Just some thoughts. – iLLin Feb 20 '17 at 14:17

This looks like a perfect use-case for hook_node_access with $op='view'. You check if the user is 'special' and apply your logic to approve/deny the view. You could have a new role for this, or a new field on the product nodes, or some other idea. It very much depends on what your logic is there.

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.