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.


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(

  $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)) {

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.