Most of us use Webform quite a bit to quickly create forms in Drupal.  It comes with a whole lot of features, but what if you need to add an additional step when the form is submitted?

When manually creating a Drupal form we use a "submit function" to process the form and save the results.  Webform doesn't give us direct access to this function, but we can add additional functions.

The solution is to create a module and use hook_form_alter to add the submit function.

You can find the form_id by viewing your HTML.

function MYMODULE_form_alter(&$form, &$form_state, $form_id) {
  if ($form_id == 'webform_client_form_123') {
    	$form['#submit'][] = 'MYMODULE_submit';
   }
}

function MYMODULE_submit($form, &$form_state) {
  // Your code goes here
}
Tags