Skip to content

Instantly share code, notes, and snippets.

@derhasi
Created December 28, 2009 16:48
Show Gist options
  • Save derhasi/264771 to your computer and use it in GitHub Desktop.
Save derhasi/264771 to your computer and use it in GitHub Desktop.
; $Id$
name = "redirectgoto"
description = "goto redirect callback"
core = 6.x
package = ZZZ
<?php
// $Id$
/**
* @file
* Callback function to do a redirect via drupal_goto and not via simply
* rendering the destination content.
* The callback will redirect to the path appended to redirectgoto/... .
* E.g. redirectgoto/node/10 will go to node/10 .
*/
/**
* Implementation of hook_menu().
*/
function redirectgoto_menu() {
$items = array();
$items['redirectgoto'] = array(
'title' => 'redirectgoto',
'description' => 'redirectgoto',
'page callback' => 'redirectgoto',
'access callback' => TRUE,
'type' => MENU_CALLBACK,
);
return $items;
}
/**
* redirectgoto callback
*/
function redirectgoto() {
$args = func_get_args();
$path = implode('/', $args);
$query = array();
// Set go back destination for anonymous users
GLOBAL $user;
if (!$user->uid) {
$query = drupal_get_destination();
}
$destination = drupal_get_destination();
//unset current destination variables to avoid loops
unset($_REQUEST['destination']);
unset($_REQUEST['edit']['destination']);
drupal_goto($path, $query, NULL, 303);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment