0

I'm trying to build a content type where any user can select an entity reference value through an autocompleted Entity Reference field.

Using this field works as an admin. I'm able to see the referenced contents. But when I try as a logged in lambda user, I can't view the content created by other users.

The field is in the content type "Invoice" and has to allow users to select a contact name (content type "Contact").

I think it's a matter of access rights on this specific content type. So far, I've tryed creating a module with a hook_node_access function :

function contact_node_access($node, $op, $account) {
  $type = is_string($node) ? $node : $node->type;

  if (in_array($type, node_permissions_get_configured_types())) {
    if ($op == 'view' && user_access('view ' . $type . ' content', $account)) {
      return NODE_ACCESS_ALLOW;
    }
  }

}

It still doesn't allow users to see and select other's people contacts.

2
  • If you can't see other peoples content, do you have any content access related modules installed, or are the nodes from other users unpublished?
    – rooby
    Commented Nov 27, 2014 at 14:08
  • Oh damn you're right... This was the problem that I didn't notice before. Thanks, you can post the answer if you want me to accept it.
    – user18713
    Commented Nov 27, 2014 at 14:14

1 Answer 1

0

Generally if a user cannot see another user's content then it is either because there is a content access module installed that is restricting access or the content is unpublished.

By default in Drupal you cannot see unpublished content unless you created it or you are an administrator with access to all content.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.