I need to be able to automatically create a default email handler upon creation of each webform with the Email To Address being the email address of the current user creating the form.

All other email handler settings can use the default values set in the main email / handler settings section.

How would I hook into and create an email handler upon web form creation using this information?

Comments

danjordan created an issue. See original summary.

jrockowitz’s picture

Use hook_webform_create() and call \Drupal\webform\Entity\Webform::addWebformHandler

danjordan’s picture

Thanks for the direction. Created the hook which returns the entity, just not exactly sure how to call addWebformHandler from within the hook with the information it requires.

The webform is only saved to memory at this stage so not sure how to add the handler

Any help would be awesome.

Thanks

jrockowitz’s picture

jrockowitz’s picture

Status: Active » Needs review
danjordan’s picture

Tested and works as expected. Thanks Jacob, your a legend.

jrockowitz’s picture

Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.