How to delete a webform submission in a custom module? I want to delete a webform submission from a custom module that I've written. I'm using webform_submission_delete(123, 76). The error I receive is:


  Notice: Trying to get property of non-object in
  webform_submission_delete() (line 141 of
  /Applications/MAMP/htdocs/mercury/sites/all/modules/webform/includes/webform.submissions.inc).
  Warning: Invalid argument supplied for foreach() in
  webform_submission_delete() (line 141 of
  /Applications/MAMP/htdocs/mercury/sites/all/modules/webform/includes/webform.submissions.inc).
  Notice: Trying to get property of non-object in
  webform_submission_delete() (line 153 of
  /Applications/MAMP/htdocs/mercury/sites/all/modules/webform/includes/webform.submissions.inc).
  Notice: Trying to get property of non-object in
  webform_submission_delete() (line 157 of
  /Applications/MAMP/htdocs/mercury/sites/all/modules/webform/includes/webform.submissions.inc).


I'm a bit new to module development. Am I missing something?
If you are calling this webform_submission_delete() function, then both the first and second parameters must be objects. At least the first parameter is a node object. Most likely you are calling this using:

$nid = 12345;
webform_submission_delete($nid, $sid);


instead of doing

$node = node_load(12345);
webform_submission_delete($node, $sid);


and as a result causing PHP to complain.

If you have doubts on how to implement webform_submissions_delete(), I suggest you take a look at the various functions that implement it for an example.