We have a Drupal 8 site running Webform 8.x-5.2. We have a special role, "Webform Editor", who is not a developer, but they are trained to create the webforms that we need for our organization.
We've been dealing with some organizational issues about who is getting what webform submission emailed to them. To help us troubleshoot the issue, we the developers want to implement a feature where each webform submission gets automatically copied (cc'ed or sent separately) to an email address that we devs have access to.
I looked at the webform module's hooks, and I didn't see any that jumped out at me as a post-submission hook. Webform version 7.x had one, but version 8.x doesn't appear to.
I made a custom submission handler, but realized I would have to add it manually to all existing webforms (we have more than I want to click through).
I began to write a form_alter
hook to add custom submit handler, but when I debugged the $form
and $form_state
, I didn't see any information (i.e. sid) about the submission record. I suppose that the submit hooks fire before the submission record is created.
In the webform cookbook, there's a recipe for "How can you automatically create a default email handler for a webform when it is created", but again, I want to automatically add this to existing webforms.
If I could do this with something like a hook, once and for all, that is what I'm looking for. If the answer is "No, you can't do what you want automatically; you'll have to make a handler and manually add it to all existing webforms", am I interested in hearing that answer, too. I don't want to chase down any more rabbit holes of approaches that won't work.
hook_entity_insert
? This hook runs once the entity has been stored. – leymannx Aug 6 '19 at 15:05