You are here

function webform_submission_delete in Webform 5.2

Same name and namespace in other branches
  1. 6.3 includes/webform.submissions.inc \webform_submission_delete()
  2. 6.2 webform_submissions.inc \webform_submission_delete()
  3. 7.4 includes/webform.submissions.inc \webform_submission_delete()
  4. 7.3 includes/webform.submissions.inc \webform_submission_delete()

Delete a single submission.

Parameters

$nid: ID of node for which this webform was submitted.

$sid: ID of submission to be deleted (from webform_submitted_data).

2 calls to webform_submission_delete()
webform_results_clear in ./webform_report.inc
Delete all submissions for a node.
webform_submission_delete_form_submit in ./webform_submissions.inc

File

./webform_submissions.inc, line 87
This file is loaded when handling submissions, either submitting new, editing, or viewing. It also contains all CRUD functions for submissions.

Code

function webform_submission_delete($node, $submission) {

  // Iterate through all components and let each do cleanup if necessary.
  webform_load_components();
  foreach ($node->webform['components'] as $cid => $component) {
    $delete_function = '_webform_delete_' . $component['type'];
    if (function_exists($delete_function) && isset($submission->data[$cid])) {
      $delete_function($submission->data[$cid], $component);
    }
  }
  db_query('DELETE FROM {webform_submitted_data} WHERE nid = %d AND sid = %d', $node->nid, $submission->sid);
  db_query('DELETE FROM {webform_submissions} WHERE nid = %d AND sid = %d', $node->nid, $submission->sid);
}