1

I have a custom redirect on node submit.

function mymodule_form_alter(&$form, $form_state, $form_id) {
    $form['actions']['submit']['#submit'][] = 'custom_node_submit';
}

function custom_node_submit($form, &$form_state) {
    $form_state['redirect'] = 'request-sent';
}

However, I would like to redirect only when a new node is created but not updated. How do I check the action being executed on the node ?

2
function mymodule_form_alter(&$form, $form_state, $form_id) {
    $form['actions']['submit']['#submit'][] = 'custom_node_submit';
}

function custom_node_submit($form, &$form_state) {
    if (arg(2) != "edit") {
      $form_state['redirect'] = 'request-sent';
    }
}
1
  • 1
    $form['#node']->is_new = TRUE for new nodes FYI.
    – AKS
    Sep 21 '12 at 10:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.