In the 'additional processing' field of my webform, I would like to send a mail to the user that includes the submission id. However, the submission id is not available at this time for newly submitted forms. This could be fixed by moving the code in webform.module, line 1502-1506 starting with '// Perform additional submit processing.' a few lines down after the block where the $sid has been created. (see attached patch). In this case the code can use the variable $sid.

However, I guess some people may want to modify the form values before the form is saved. So maybe we need a third block to be called after the form has been submitted? Or it should be documented clearly that such code should go into the validation section, which is clearly executed before the form is submitted?

In any case, the patch solved the problem for me: pre-submit code goes into the validation section, post submit code has a submission id as variable $sid.

CommentFileSizeAuthor
webform.patch1.17 KBBodo Maass

Comments

Bodo Maass’s picture

Status: Active » Needs review
quicksketch’s picture

I don't think we can really move the processing code as, like you say, users may use it to change a submission before it is saved to the database. Could you use the "Confirmation message" as PHP to do any last minute processing, after the sid has been generated? You can check $_GET['sid'] to look at things after the form has been submitted.

quicksketch’s picture

Status: Needs review » Closed (works as designed)

Hopefully the 2.x version will solve your problem. Now you can theme individual e-mails and send out e-mails per-component without any coding by using the new "Conditional e-mail recipients" field.

Since we can't move this code without breaking a lot of sites, I'm going to mark by design. Please open a new ticket if you have trouble with the 2.x version.

Bodo Maass’s picture

Thanks for your work. The project for which I made my last webform is already in production, and I don't have time to play with this right now, but I will give the new version a try in a few weeks or so.

armyofda12mnkeys’s picture

Version: 5.x-1.x-dev » 6.x-2.1.3

I used your idea for '3rd processing' option temporarily and put code for that to eval that after update/insert (couldnt use GET['sid'] for some reason, as i do a confirmation redirect ($node->webform['confirmation']) to the next webform in the group, and from node/17 pretend, the browser goes to node/18?sid=58, but GET['sid'] has no value it seems there when run in the 2nd Additional Processing field... $GET just had array('q' => node/17) since i guess hasnt redirected yet ).

What I do currently is I link multiple webforms together with a custom module (versus using multiple pages which may have certain disadvantages), and when submitted, I see if all the webforms in that webform group is submitted, then generate an email based on a component if they are all finished (and this code is placed in the 3rd processing field to run on each webform in that group to do this check).

lokisapocalypse’s picture

This patch no longer works as _webform_update_submission now gives a fatal error.

ken hawkins’s picture

I happened upon this thread when searching for a 3.x solution. This is the fix I came up with if someone else should be in the same boat http://drupal.org/node/1224182