When I create a new node in my website, I want to be redirect to the edit page of the new node. I see several hook, but according to this post its not possible use drupal_goto..
Is there a way for me ? I prefer a programming approach Thanks =)
When I create a new node in my website, I want to be redirect to the edit page of the new node. I see several hook, but according to this post its not possible use drupal_goto..
Is there a way for me ? I prefer a programming approach Thanks =)
In a custom module, use this code, and don't forget to replace MYMODULE_ with your module machine name :
function MYMODULE_form_alter(&$form, &$form_state, $form_id) {
switch ($form_id) {
case 'my_content_type_node_form': // Replace my_content_type with yours
$form['#submit'] = array_merge(array('MYMODULE_my_content_type_node_form_submit'), $form['#submit']);
break;
}
function MYMODULE_my_content_type_node_form_submit(&$form, &$form_state) {
$initial_values = $form_state['build_info']['args'][0];
$form_state['redirect'][] = drupal_get_destination();
$form_state['redirect'][] = array('destination' => 'node/' . $initial_values->nid . '/edit');
unset($_GET['destination']);
$_GET['destination'] = 'node/' . $initial_values->nid . '/edit';
drupal_static_reset('drupal_get_destination');
drupal_get_destination();
}