1

I am using ACL module to set user wise permission . Its working fine and I am able to set permission user wise from admin access.

What I need:

I have the nid and uid and I wants to set node view access permission to that user programmatically.

1

You may want to program it yourself, you can have something like this, probably implementing hook_init():

function my_module_init() {
  global $user;

  $nid = 85; // We'll check node 85.

  // Users with access:
  $uids = array(
    3,
    9,
    11,
  );

  $node_path = 'node/' . $nid;

  // Check if the user is in the node detail.
  if (current_path() == $node_path) {
    // Check if the user is not in the list of allowed users.
    if (!in_array($user->uid, $uids)) {
      drupal_access_denied();
    }
  }
}

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.