[development] Using drupal_access_denied()

David T david.hart at gmail.com
Tue Mar 23 12:16:58 UTC 2010


Hi,

Although I've managed to implement some functionality using Rules, for
various reasons I'd like to shift it to some logic and code in my own
custom module that prevents access to certain pages.

Doing:

function mymodule_preprocess_page(&$vars) {
  if ($some_condition) {
    print "pass";
  } else {
   print "fail";
  }
}

works fine.

If I do:

function mymodule_preprocess_page(&$vars) {
  if ($some_condition) {
    drupal_access_denied();
    exit;
  }
}

I just get a white page (which is a 403 page looking at the header, not a 500).

What do I need to do instead?

Cheers,

David


More information about the development mailing list