By merrillbros on
Hello!
I am trying to use drupal_goto() inside hook_submit() but when drupal_goto() gets executed the node will not be updated.
Does anyone know how to send the user to another page other than the default node view page after hook_submit() is executed?
Thanks
Comments
can you post the code inside
can you post the code inside your hook call? :)
RTFM!
For further support or projects contact me.
Source Control - Web Design, Development and Hosting Oxfordshire, UK
function
Whoops I am in hook_submit().
So if I take out drupal_goto() the node will update. I put it back in the node will NOT update.
ah, well this might help
ah, well this might help :P
should be
quotes in php can be a bit funny, double quotes will handle the addition of variables, single quotes treat everything as a string, so at the moment your passing $redirect_url as a string, rather than the value it contains. just drop the single quotes from around it (no quotes are needed).
test that out, shout when you have a result or not :), but that's a good place to start.
RTFM!
For further support or projects contact me.
Source Control - Web Design, Development and Hosting Oxfordshire, UK
Thanks! drupal_goto($redirect
Thanks!
drupal_goto($redirect_url);I changed it and ran it same thing : (
When drupal_goto() gets executed the changes to the node do not get submitted.
But if I comment out drupal_goto() the node will be updated.
Trying to get this redirect to work.
ok, looking through some of
ok, looking through some of the stuff I've done in the past... (bit of a shot in the dark here) it seems that because your calling drupal_goto() before the end of the function (changing the headers), the form_state data is not being stored in the referenced array. try returning drupal_goto()
i say again, this is a bit of a shot in the dark :)
try this:
RTFM!
For further support or projects contact me.
Source Control - Web Design, Development and Hosting Oxfordshire, UK
haha we think very alike. I
haha we think very alike.
I tried using return earlier and still no avail.
I tried it again and the changes do not get submitted : (
hook_submit needs to return the $node in order to make the updates.
I thought about making another function outside of the hook_submit maybe that will work...
That still doesnt work
Try Nevets solution below,
Try Nevets solution below, definitely a better way of doing it and should work no problem :)
RTFM!
For further support or projects contact me.
Source Control - Web Design, Development and Hosting Oxfordshire, UK
Instead of try
Instead of try drupal_goto('$redirect_url');
well, that beats my
well, that beats my suggestion...
kudos :D
RTFM!
For further support or projects contact me.
Source Control - Web Design, Development and Hosting Oxfordshire, UK
function
The node will update now but it still goes to node the was being updated.
I read up on $form_state['redirect'] and it sounds like it should do the trick.
When I print $form_state['redirect'] its value is 'form'.....
Any more ideas?
Thanks a lot again.
Is 'form' a valid path?
Is 'form' a valid path?
Yes it is.
Yes it is.
I just checked:
$form_state['no_redirect']
It did not have a value...
Also tried this:
call_user_func_array('drupal_goto', $form_state['redirect']);
and this:
$form_state['redirect'] = drupal_goto('form');
From this article:
http://api.drupal.org/api/drupal/includes!form.inc/function/drupal_redir...
Looking at node_form_submit()
Looking at node_form_submit() this will not work since it has a hard coded redirect. You would need to use hook_form_alter() to change the submit handler to on you write that replicated node_form_submit() but without the hard coded redirect.
use this
use either
$form_state['redirect'] = $redirect_url;or
$_GET['destination']=$redirect_url;drupal_goto is wrong way to accomplish this. If your other module is using node_insert/node_update then this will not work.
chetan
$_GET['destination']=$redirec
$_GET['destination']=$redirect_url;
This worked!!!
Thanks everyone for all the help!