Skip to content

Instantly share code, notes, and snippets.

@opi
Created January 9, 2012 11:56
Show Gist options
  • Save opi/1582649 to your computer and use it in GitHub Desktop.
Save opi/1582649 to your computer and use it in GitHub Desktop.
Drupal: Front theme on error 403 (Access denied)
<?php
// To enable this, set 403 path to 'error-403' on admin/settings/error-reporting
// or do variable_set('site_403', 'error-403'); in a hook_update_N, in your .install file.
function mymodule_menu() {
return array(
'error-403' => array(
'title' => "Access denied",
'page callback' => 'mymodule_error_403',
'access arguments' => array('access content'),
),
);
}
function mymodule_error_403() {
// Always display front theme
global $custom_theme;
$custom_theme = FALSE;
// Mimic default drupal 403
drupal_set_title(t("Access denied"));
return t("You are not authorized to access this page.");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment