Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Problem
Notification emails need to sent to all users assigned to specific role.
Solution
Allow 'To', 'Cc', and 'Bcc' email addresses to be populated using selected roles.
Tasks
- Update admin settings form. (email_roles)
- Update admin settings scheme. (email_roles)
- Refactor recipient email element.
- Update email handler configuration form. (EmailWebformHandler::buildConfigurationForm)
- Add 'Email roles' checkbox with hide/show logic. (to_roles, cc_roles, bcc_roles)
- Update email send method (EmailWebformHandler::getMessage)
- Update email summary to support selected roles.
- Add custom support for 'authenticated' role.
- Make sure roles are rechecked before sending email.
- Update email debugger.
- Write update hook to update all existing email handlers.
- Write tests.
Notes
- Add warning 'You must select each role the can be emailed via a Webform email handler. If not roles are selected this feature will be disabled'
- Rules module could support this feature but UX would not be as clean or secure. @see http://drupal.stackexchange.com/questions/140617/send-email-to-specific-...
Comment | File | Size | Author |
---|---|---|---|
#14 | allow_emails_to_be_sent-2856842-13.patch | 6.63 KB | jrockowitz |
| |||
#14 | Screen Shot 2017-03-27 at 6.08.07 AM.png | 31.01 KB | jrockowitz |
#9 | allow_emails_to_be_sent-2856842-8.patch | 31.65 KB | jrockowitz |
| |||
#6 | allow_emails_to_be_sent-2856842-5.patch | 31.47 KB | jrockowitz |
Comments
Comment #2
jrockowitz CreditAttribution: jrockowitz as a volunteer and at The Big Blue House commentedComment #6
jrockowitz CreditAttribution: jrockowitz as a volunteer and at The Big Blue House commentedComment #9
jrockowitz CreditAttribution: jrockowitz as a volunteer and at The Big Blue House commentedComment #11
jrockowitz CreditAttribution: jrockowitz as a volunteer and at The Big Blue House commentedComment #12
kclarkson CreditAttribution: kclarkson commentedJake,
After a few different token combinations I was able to get the feature working. Here are a couple of issues that I am seeing.
1. The token suggestion should include the "mail" part. Right now the token suggestion is: [webform_role:name] it should read - [webform_role:name:mail]
I know you put it in the notes but it was a little difficult to find. I know for a lot of site builders they are probably expecting a check box but I know this isn't necessary. Just a better description in the token suggestions. Also the example in the notes has the format with the curly braces [webform_role:{name}:mail] . The curly braces can throw you off. Seeming that tokens in Views is now TWIG, the curly braces I thought were a part of the twig token.
2. The email handler is setup to fire on the "creation" of submission. We need the handler to also fire on 'update' of submission.
The use case for the application review is to be able to have a hidden field on a submission, allow a person to change that field and when that field is changed the email handler fires and emails out.
Comment #14
jrockowitz CreditAttribution: jrockowitz as a volunteer and at The Big Blue House commented1. I am just going to remove the ':mail' from webform role token and display all available roles. (ie [webform_role:authenticated], [webform_role:administrator], etc...)
2. Needs to addressed in new ticket which I can create.
Comment #17
jrockowitz CreditAttribution: jrockowitz as a volunteer and at The Big Blue House commented@kclarkson I committed the update. Please review.
Comment #18
jrockowitz CreditAttribution: jrockowitz as a volunteer and at The Big Blue House commentedComment #19
kclarkson CreditAttribution: kclarkson commented@jake,
Much and improved sir.
1. The tokens are just a copy and paste for the user-role - Awesome!!!
2. Providing checkboxes for when to send emails (updat, delete, submission etc.) provides a nice and clean touch. - Awesome!!!
This is perfect for quite a little mini workflow based on webform fields. I can now have the application use a field at which I can set visible to just a Pre-Reviewer. After the application submission I can fire a email confirmation to the end user, send an email to the "Pre-Reviewer", then the pre-reviewer can change a status field on the submission and then it fires an email to everyone with the "Reviewer Role" that says available for review.
Fixed Fixed and Fixed!
Comment #20
jrockowitz CreditAttribution: jrockowitz as a volunteer and at The Big Blue House for Kennesaw State University commentedComment #22
CLKeenan CreditAttribution: CLKeenan commentedAw man. This is exactly what I need for the D7 version of webform! Any plans on backporting this to D7.4?
Comment #23
sorin_cocorada CreditAttribution: sorin_cocorada commentedHello,
Would it be possible, using this approach, to send emails to a dynamically generated role?
Use case: I want to send emails (when the webform is submitted, updated and so on) to a role which depends on a webform submission value.
Thanks!
Comment #24
demonde CreditAttribution: demonde commentedIf I get it right, there is no way to send an email to a submitter that has a specific role by this function. Emails will be send to all users that have a specific role here.