Drupal 7: Two submit buttons and custom field validation I have a custom user registration form (D7). I added two custom submit buttons inside THEME_form_alter

  $form['actions']['submit'] = array(
    '#type' =&gt; 'submit', 
    '#value' =&gt; t('Sign Up')
  );
  $form['actions']['submit2'] = array(
    '#type' =&gt; 'submit', 
    '#value' =&gt; t('Sign Up &amp; Take Survey')
  );


These render fine and both handle the registration equally well but when submit2 is clicked I want to redirect to a webform survey.

I added the following:

function tweakform_user_register_submit($form, &amp;$form_state) {

  if($form_state['values']['op'] == $form_state['values']['submit2']) {
    echo 'Redirect to survey and populate fields with user details';
    exit;
  }  

}


I refreshed the cache and this function does not seem to be invoked.

Alex
I'd suggest using the #submit property

For example:

$form['actions']['submit'] = array(
 '#type' =&gt; 'submit', 
 '#value' =&gt; t('Sign Up')
);
$form['actions']['submit2'] = array(
  '#type' =&gt; 'submit', 
  '#value' =&gt; t('Sign Up &amp; Take Survey')
  '#submit' =&gt; array('custom_submit_for_this_button')
);


And then:

function your_form_name_submit($form, &amp;$form_state) {
  // your logic for first button here; this is auto-called by Drupal
}
function custom_submit_for_this_button($form, &amp;$form_state) {
  // your logic for second button here
}