Contextual information on custom Access Denied page I'm trying to implement my own access denied page, and I'd like to get some information about the context of the access being denied... for example, if the user is on a specific node type page, I'd like to still display a short snippet of that node before the access denied message, so the user knows he's at least in the right part of my site.

However, I can't use menu_get_object(), as arg(0) simply returns 'access denied' in my page callback. Is there any way of passing in the path information for an access denied page? See my code below:

&lt;?php
/**
 * Implements hook_menu().
 */
function custom_menu() {
  $items['access-denied'] = array(
    'title' =&gt; 'Access Denied',
    'page callback' =&gt; 'custom_access_denied',
    'access arguments' =&gt; array('access content'),
    'type' =&gt; MENU_CALLBACK,
  );
  return $items;
}
?&gt;


And in my page callback:

&lt;?php
/**
 * Access Denied page.
 */
function fn_custom_access_denied() {
  global $user;
  $html = '';

  // Display access denied message and login form for anonymous users.
  if (!$user-&gt;uid) {
    $html .= '&lt;p&gt;' . t('The content you are trying to access is protected. Please log in or create an account to view the page.') . '&lt;/p&gt;';
    $html .= drupal_render(drupal_get_form('user_login'));
    drupal_set_title('Login Required');
  }

  // Display access denied message for logged-in users.
  if ($user-&gt;uid) {
    $html .= '&lt;p&gt;' . t('The content you are trying to access is protected.') . '&lt;/p&gt;';
    drupal_set_title('Private Content');
  }

  return $html;
}
?&gt;
Supposing that the site is using clean URLs, I would rather use the following code:

function fn_custom_access_denied() {
  $path = drupal_get_normal_path(trim($_SERVER['REQUEST_URI'], '/'));

  if (($node = menu_get_object('node', 1, $path)) &amp;&amp; ($node-&gt;type == 'event')) {
    drupal_set_message(t("%event is a private event.", array('%event' =&gt; $node-&gt;title));
  }

  return "";
}