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.
Drupal Answers is a question and answer site for Drupal developers and administrators. It only takes a minute to sign up.
Sign up to join this communityYou 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();
}
}
}