The Workbench Email module allows site builders to configure emails that can be sent when the state of a piece content changes using the Workbench suite. The email subject and message are fully configurable from Drupal’s administration section, as well as defining which transition an email can be sent (draft to needs review).
For example, you can define an email that’ll be sent when a content’s Moderation state is changed from Draft to Needs Review. This means that you can have a writer who creates a Draft article, and then once it’s ready to be reviewed they’ll change the article state to Needs Review and choose a user who should receive the email.
In this tutorial, we’ll configure Workbench Email to allow authors to send an email when the state changes from Draft to Needs Review and Needs Review back to Draft.
I’ll assume you already have a basic setup of Workbench and Workbench Moderation. Configuring Workbench is outside of the scope of this tutorial. If you need help with Workbench, review at the documentation page.
If you use Drush, run the following command.
$ drush dl workbench_email workbench_moderation token
For my basic Workbench setup, I have two roles: writer and editor. A writer has permission to create an article and change the state to Needs Review. An editor can publish an article or move it back to a Draft state.
Configure Workbench Email
The first bit of work we’ll need to do is choose which transitions should send off an email.
1. Go to Configuration -> “Workbench Moderation” (admin/config/workbench/moderation) and click on the “Email Transitions” tab.
2. Select which user role should receive an email for a specific transition. For my setup, I chose Editor for “Draft –> Needs Review” and Writer for “Needs Review –> Draft”.
If you can’t see any checkboxes on the “Email Transitions” page, this means you haven’t setup any roles or permissions to work with Workbench Moderation.
3. Now we’ll need to configure the emails that will be sent when the state changes. Click on the Email tab next to “Email Transitions”.
4. Click on the “Draft To Needs Review” link and “Email Editor”. Enter
"[node:title]" needs to be reviewed into the Subject text field and
Article "[node:title]" needs to be reviewed. into the Message text area.
Also, don’t forget to configure the “Needs Review To Draft” email. Once you’re done, scroll to the bottom and click on “Save configuration”.
Workbench Email in Action
Go and create an article using a “writer” user and when you change the “Moderation state” to “Needs review” you should see a multi-select box appear. Select the user who should receive the email and click Save.
Note: There is an issue where you can’t notify multiple users. Drupal issue #1899054.
If everything has been setup properly, the selected user should have received an email. Finally, if you don’t want to send an email notification then just select “- None -” from the multi-select box and click on Save.
If you have any questions, please leave a comment.