You are here

function customerror_drupal_goto_alter in Customerror 7

Implements hook_drupal_goto_alter().

File

./customerror.module, line 293
Enables custom 404 (not found) and 403 (access denied) pages in Drupal.

Code

function customerror_drupal_goto_alter(&$path, &$options, &$http_response_code) {
  if (!user_is_logged_in() || !isset($_SESSION['customerror_destination'])) {
    return;
  }
  $dest = drupal_parse_url($_SESSION['customerror_destination']);

  // If the password reset token is set: user needs a chance to change password.
  if (isset($options['query']['pass-reset-token'])) {
    $options['query']['destination'] = $dest['path'];
  }
  else {
    $path = $dest['path'];
    unset($dest['path']);
    $options += $dest;
  }
  unset($_SESSION['customerror_destination']);
}