How can I detect 'access denied' and 'page not found' error pages from a contributed module? How is it possible to find out whether the page currently viewed is such a page or loaded correctly? The path seems to stay the same. For example: a user tries to access node/xy, but he/she does not have the proper permission to view that page, so the user is directed to 'access denied' page (the path however is still node/xy). Is there any global variable or stg. reflecting the 403 state? How is this handled internally? Can I hook into error pages from contrib modules?

Comments

Zen’s picture

Perhaps looking at/using the customerror module might help?

-K

jacobfriis’s picture

($status = drupal_get_http_header('status')) && strpos($status, '200') !== 0

/**
 * Example, some block module.
 *
 * Implements hook_block_view().
 * @param string $delta
 * @return array
 */
function some_block_module_block_view($delta) {
  //  If status header sent, and it isn't 200: Get out.
  if(($status = drupal_get_http_header('status')) && strpos($status, '200') !== 0) {
    return array();
  }
  //  ...
}