Drupal - Handle Existing Webform Submission Edits
If you need to do something when a user edits/updates a previous webform submission, try something like this:
function tf_form_alter(&$form, $form_state, $form_id) { if (strpos($form_id,"webform_client_form_") !== false) { // edit webform client form... if (!empty($form['#submission'])) { // editing a previous submission... $form['#submit'][] = "_tf_webform_client_form_submit_handler"; } else { // new submission... } } } function _tf_webform_client_form_submit_handler ($form, &$form_state) { if ($_GET['destination']) { /* the user clicked the 'edit' button on node/%/submissions page */ } else { /* the user clicked the 'edit' tab local task on the submission view page */ } // show a warning link which suggests the user have the webform submission e-mail notification resent drupal_set_message( l( "Please consider clicking here to notify this form's administrator", "node/" . $form['#node']->nid . "/submission/" . $form['#submission']->sid . "/resend" ) . " if you have made changes to your submission.", "warning" ); }
The code above attaches a custom submit handler to webform client forms for previously submitted webform submissions.
The submit handler has two optional conditionals to choose what to do depending on how the user got to the submission edit form. The submit handler also provides a Drupal warning message with a quick link to encourage users to have the e-mail notifications sent again.
It would be awesome if Webform Rules had an event trigger for this, but alas, it does not. I put in a request for it here. Hopefully this code can be used as a base to get started on a patch for the requested feature.