Stop node being edited programatically I have written a module that puts a "generate pdf" link on a node when it is viewed. What I now want to do is lock the original node after the pdf is generated.

I know I could just add a "locked" field to the content type I want to lock, and then programatically set that etc. But I'd prefer it to work with any content type.

How can I programatically disable the editing of a node? I'd prefer to install as few additional modules as possible.
For this you should have to implement hook_node_grants and hook_node_access_records. It look something like that -

 /**
  * Implement @hook_node_grants 
  */
 function MODULENAME_node_grants($account, $op) {

  $grants =array();
  $grants['Node_Edit_Permission'][]=array($account-&gt;uid);
 return $grants;
}

/**
 * Implement @hook_node_access_records
 */
function MODULENAME_node_access_records($node) {

  $grants = array();

  if ($node-&gt;type == 'node_type') { 
    $user_id = /* list of user id which you want to block */;

     // Revoke Permissions from these Users
    if (!empty($user_id) {
      foreach ($user_id as $uid) {
        if (isset($uid)) {

          $grants[] = array(
            'realm' =&gt; 'Node_Edit_Permission',
            'gid' =&gt; $uid,
            'grant_view' =&gt; 1,
            'grant_update' =&gt; 0,
            'grant_delete' =&gt; 0,
            'priority' =&gt; 0,
          );
        }
      }
    }
  }

  return $grants;
}