Redirect in a callback of type MENU_CALLBACK
Why doesn't drupal_goto()
work in my menu callback?
function _mymodule_mycallback() {
global $user;
$nid = arg(1);
// needed for node_object_prepare
module_load_include('inc', 'node', 'node.pages'); // needed for node_object_prepare()
$new_node = (object) array();
$new_node->type = 'auction';
$new_node->language = '';
node_object_prepare($new_node);
node_save($new_node);
$new_nid = $new_node->nid;
drupal_goto('node/'.$new_nid, drupal_get_destination());
exit();
}
I always get back t开发者_JAVA技巧o the calling site. I already tried url()
and sending headers but it doesn't work.
UPDATE
try an unset($_REQUEST['destination']);
(and possibly also an unset($_REQUEST['edit']['destination'])
before the call to drupal_goto()
if latter doesn't seem to work.
UPDATE END
try just
drupal_goto("node/$new_nid");
(without drupal_get_destination();
also the exit();
is superfluous - see the doc)
精彩评论