I have 2 content types:

  • Project.
  • Proposal.

The Proposal content type has a field reference to the Project content type.

I want to give view access to "Proposal"s only for the user who created the "Project" which the "Proposal" is referenced to.

Any suggestions to help me resolving this problem?


I think you will have to write a custom module to do this. I would suggest implementing the hook hook_node_access

function <mymodule>_node_access($node, $op, $account) {
   if ($node->type == 'proposal' && op == 'view') {
       $project_node = node_load($node->fields-><project reference>['und'][0]['value']);
       // If the project node is created by the current user, then grant access
       if ($project_node->uid == $account->uid) {
           return NODE_ACCESS_IGNORE;
       } else {
           return NODE_ACCESS_DENY;
| improve this answer | |
  • @TheBarnacle your code is missing a detail, the if's condition should be: if ($node->type == 'proposal' && op == 'view') { ;) I would also like to highlight an important matter. As stated in the documentation page of hook_node_access: "Also note that this function isn't called for node listings (e.g., RSS feeds, the default home page at path 'node', a recent content block, etc.)", read this for more details – user1527576 Aug 16 '15 at 17:10

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.