1

So far i have this code in mymodule.module:

function mymodule_form_alter(&$form, $form_state, $form_id) {
    //drupal_set_message($form_id);
    switch ($form_id) {

        case 'anons_node_form':
          //dpm($form);
          $form['#submit'][] = 'sex_custom_submit';

          break;
    }
}

//Custom submit handler
function sex_custom_submit($form, &$form_state) {
  $form_state['rebuild'] = TRUE;
  $form_state['redirect'] = '/video';
}

In a short i want this thing - when a user creates a node type 'anons' after succesfull creation of that node -> user should be redirected to a /video page. Code above doesn't works for me.. What i am doing wrong?

1
  • 2
    Why not sure Rules framework?
    – saadlulu
    Commented Oct 12, 2012 at 14:59

2 Answers 2

2

Try putting your destination as GET destination parameter, i:e $_GET['destination']. The GET destination parameter gets the highest preference

0

Your redirect isn't happening because you have set $form_state['rebuild'] = TRUE; which prevents the redirect from happening.

For appropriate documentation see drupal_redirect_form

2
  • With false its not working too Commented Oct 12, 2012 at 15:31
  • 1
    Have you read the documentation at the link I provided? It lists a bunch of reasons why the redirect may not be happening.
    – jmarkel
    Commented Oct 12, 2012 at 15:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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