Individual nodes of a content type need to have their edit capability for a role removed after a date provided by a CCK field. The idea is that these nodes are entered by various roles, given a "start date" and displayed on the site in a few layouts. After the start date has passed, the node should be uneditable by this specific role.

How can this be achieved, is it possible by using a module-only method or can it be done in code?


Yes, you can do that with


For example, something like:

 * Implements hook_node_access().
function MODULE_node_access($node, $op, $account) {

  // If editing target node type
  if ($op == "edit" && $node->type == 'target_type') {
    // Check against passed account or current user
    if (empty($account)) {
      $account = $GLOBALS['user'];
    // If date field is set, user has target role and date is in the past
      $date = $node->field_target_date[LANGAUGE_NONE][0]['value'];
      if((in_array('target_role', $account->roles)) && (REQUEST_TIME > strtotime($date))){
        // Deny edit access
        return NODE_ACCESS_DENY;



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.