I would like to redirect users to an access denied page, if they try to edit a page with a specific CCK field value.

Any tips?


Since you mention CCK and not fields, I am assuming Drupal 6 here. A brute force approach would look like

function foo_init ()
  if (arg(0) == "node" && arg(2) == "edit") {
    $nid = (int) arg(1);
    $node = node_load($nid);
    if ($node && $node->nid) {
      $foo = $node->field_foo[0]["value"];
      if ($foo == "foo") {
| improve this answer | |

What you want is probably a custom node_access module - just remember that permissions in Drupal are additive, so your custom module is granting permission, rather than taking it away. So, for instance, a user should not already have the "edit this content type" permission or they'll have it for ALL nodes of that content type.

Also, why even assume they can attempt to edit? If they don't have permissions to edit that page, short of them manually hitting the /edit URL for a node, they're not going to have a chance - no edit button will be visible.

| improve this answer | |

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.