When a form is in a block on a page, I'd like an email to be sent to the page author when the form is submitted. Obviously this could only work when the form was placed on a page that had an author.
I managed to get this working on Drupal 7 Webforms by using the Custom Token module to create a page-author token that was placed in a hidden field (as a secure value so the actual email address wasn't embedded on the page) on the form that could then be used as the to address for the email.
I have tried to get this working with Drupal 8 Webforms but right now the Custom Token module only has a dev release and there doesn't appear to be an equivalent of the old secure hidden field.
Comments
Comment #2
jrockowitz CreditAttribution: jrockowitz commentedBelow is the needed token
[webform-submission:source-entity:author:mail]
I am going to improve the Webform token descriptions to make it easier for people to figure out what tokens are available.
Comment #3
whizzkid CreditAttribution: whizzkid commentedThat's great.
I can confirm that setting the To Email setting to Custom to email address and setting the value to [webform-submission:source-entity:author:mail] works exactly how I want.
It wasn't obvious that tokens were allowed in that field.
Not that it is needed for this any more, it seems there is an equivalent of the old secure hidden field: Value Elements.
@jrockowitz - thanks for both tips!
Comment #4
jrockowitz CreditAttribution: jrockowitz commentedI am going to #2834572: Refactor and improve token management and add a [webform_submission:node:?] token which should make it easier for people to figure out how to access a webform's node's field and author.
Comment #5
Kenneth _Paris CreditAttribution: Kenneth _Paris commented#3 works as expected for me.
Comment #6
frankdesign CreditAttribution: frankdesign commented@jrockowitz - thanks for the info at #2 - works perfectly for me - users can send an email to the Node Author on nodes where I have the Webform Block displayed.
I also want to include the Node Authors name in the Body of the email, but if I try [webform-submission:source-entity:author:account-name] or [webform-submission:source-entity:author:display-name] in the Body of the email, I get an error saying the token is not valid. Is it not possible to include those tokens in the Email Body?
Thanks
F