Submission hook: What am I doing wrong? EDIT: Still need some help with this. It seems the value of "$form_id" is nothing related to "webform_client...". When I echo the value of $form_id in the mywebform_extra_form_alter() function it outputs a value of: "search_form_block".. nothing indicating a webform.

Can I ask for some more assistance with this?

I've created a module for a webform submission hook to open and modify a CSV with the submitted values:



function mywebform_extra_form_alter(&amp;$form, &amp;$form_state, $form_id) {
    // Add validation for a particular Webform node:
    if ($form_id == 'webform_client_form_213') {
    // Add the submit handler after the existing Webform submit handler,
    // but before the second Webform handler. Pop off the first one and add
// ours second.
    $first = array_shift($form['#submit']);
    array_unshift($form['#submit'], $first, 'mywebform_extra_submit_213');
  }
}

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

    global $user;

    // Changes can be made to the Webform node settings by modifying this variable:
    $form['#node']-&gt;webform;

    $name = $form_state['values']['your_name'];
    $email = $form_state['values']['your_e_mail_address'];
    $zip_code = $form_state['values']['zip_code'];
    $date = date('m/d/Y');

    $handle = fopen("pledge_submissions.csv", "a");
    $line = array($name,$email,$zip_code,$date);
    fputcsv($handle, $line);
    fclose($handle);

}


It seems these functions are firing but when I open the CSV, no data has been added.

Is $form_state['values']['field_name_here'] the correct way to target the webform field values? When I try to alert things inside that function the form errors out after submission.
Two things:

Check your argument to fopen for validity, and two, the $form_state in Webform is missing a key. Example:

  $data = array(
    'full_name' =&gt; $form_state['values']['submitted']['full_name'],
    'company' =&gt; $form_state['values']['submitted']['company'],
    'phone' =&gt; $form_state['values']['submitted']['phone'],
    'email_address' =&gt; $form_state['values']['submitted']['email_address'],
    'areas_of_interest' =&gt; array(),
    'comments' =&gt; $form_state['values']['submitted']['comments'],
  );


You are missing ['submitted'].