Last updated May 16, 2014. Created on January 14, 2011.
Edited by droetker, mitchell, sillygwailo, miller.t.chris@gmail.com. Log in to edit this page.

Based on the instructions at http://drupal.org/node/550716

Modules needed

Create workflow field

  1. Go to the "Manage fields" page of the Article content type (admin/content/node-type/article/fields).
  2. Fill out a new field with "Workflow" as label, "workflow" as machine readable name, select "List (text)" as data type and select "Select list" as form element.
  3. Click "Save".
  4. In the next form, check all the permissions and set the allowed values to:
    Draft
    Needs Review
    Reviewed
    Needs work
    Published
  5. Hit "Save field settings".
  6. Make the field required by checking the "Required field" box.
  7. Make the field accept a single value.

Activate the Rules & Field Permissions modules

  1. Go to "admin/modules" on your site and activate "Rules", "Rules Administration UI", "Rules Scheduler", "Field Permissions", and "Entity API" modules.
  2. Go to the configuration page of the article content type (admin/structure/types/manage/article), under "Publishing options", deactivate the checkbox "Published" and click "Save content type" (we do not want to publish content by default, we will do publishing rule-based).

Create user roles "Editor" and "Publisher"

  1. Go to the user roles page (admin/people/permissions/roles).
  2. Fill out the empty text field with "Editor" and click "Add role".
  3. Click "edit permissions" of the Editor role and grant the following minimum permissions:
    • Edit any field_workflow
    • Edit own field_workflow
    • View any field_workflow
    • View own field_workflow
    • View published content
    • Article: Create new content
    • Article: Edit own content
    • Article: Edit any content
    • Article: Delete own content
  4. Do exactly the same for the "Publisher" role.
  5. Go to the users page (admin/people), edit users and assign them editor or publisher roles, when appropriate.

Create rules to publish the content

We want to publish the content, if a publisher sets the Workflow field to "Published".

  1. Go to the triggered rules page (admin/config/workflow/rules) and click on "Add a new rule".
  2. Fill out the label with "Publish article" and select "Before saving content" from the event box.
  3. Hit "Save changes" to create the rule.
  4. On the resulting page click "Add a condition" and select "Content has type".
  5. Click "Next", select "Article" from the content types and click "Save".
  6. Add another condition: "User has role(s)". Click "Next":
    • Data selector: site:current-user
    • role: "Publisher"
  7. Add another condition: "Data comparison"
    • Data selector: node:field-workflow
    • Continue
    • Operator Value: equals
    • Data Value: Published
  8. Now add an action: "Publish content". Click "Next" and then "Save".

Enable form events

TODO: update this section when Rules: Form Events is available for Drupal 7

  1. We want to display an error message to users of the editor role when they want to publish content (only publishers are allowed to do so). Therefore we need Rules form support and we need to activate events on the "Create article" form.
  2. Go to the Rules form events page (admin/rules/forms)
  3. Check "Enable event activation messages on forms" and "Display form element IDs" and click "Save settings".
  4. Go to to the "Create article" form (node/add/article).
  5. You should see a drupal message saying "Activate events for article_node_form", click the link "article_node_form" and confirm the activation on the following page.

Create a rule to set unpublished content automatically to "Needs work" after 2 weeks

Now we want to set the workflow to "Needs work", if there has been no activity in 2 weeks. We will use Rules Scheduler for that (have a look at Tutorial 2 that deals with a similar issue).

  1. Add a rule set (admin/rule/rule_sets), label "Set workflow to needs work", machine name "set_workflow_needs_work".
  2. Specify an argument, type "Content", label "Content", machine name "node" and click "Save".
  3. Click on the new rule set and add a new rule with label "Set workflow to needs work".
  4. Add a condition "Field has value", select "field_workflow", select "Published" as Workflow and check the "Negate" box.
  5. Add an action "Populate a field", select "field_workflow" as field and select "Needs work" as Workflow.
  6. Got to the triggered rules page and add a new rule, label "Schedule Needs work after 2 weeks" and event "After creating new content".
  7. Add a condition "Content has type" and select "Article".
  8. Add a condition "Field has value", select "field_workflow", select "Published" as Workflow and check the "Negate" box.
  9. Add an action "Schedule Set workflow to needs work", insert "workflow [node:nid]" into the identifier field and "+2 weeks" into the scheduled evaluation date field.
  10. Go to the triggered rules page, clone the new rule and change the event to "After updating existing content" (we also want to affect updated content).

Create rules to send an e-mail to editors

We want to send an e-mail to all editors if content is created or the workflow state has changed.

  1. Go to the triggered rules page and add a new rule, label "Send e-mail to editors on creation" and event "After saving new content".
  2. Add a condition "Content has type" and select "Article".
  3. Add an action "Send a mail to all users of a role" and select "Editor" as role.
  4. Enter a subject like "New content: '[node:title]" and a message like "New content has been created by [node:author] and the workflow is set to [[node:field-workflow]. Link: [site:url]/node/[node:nid]".
  5. Go to the triggered rules page and add a new rule, label "Send e-mail to editors on workflow change" and event "Before saving content".
    • First condition: "Content has type" -> Article
    • Second condition:
      • Data selector: node-unchanged:field-workflow
      • Data value: node:field-workflow
      • Check Negate

Email notifications

  1. Add an action "Send a mail to all users of a role" and select "Editor" as role.
  2. Enter a subject like "Workflow on '[node:title]' has changed" and a message like "The workflow has changed from [node_unchanged:field-workflow] to [node:field-workflow]. Link: [site-url]/node/[node:nid]".

Create a rule to send an e-mail to publishers

We want to send an e-mail to all publishers if the workflow state is set to "Reviewed" (we do not want to send them mails on every workflow change).

  1. Go to the triggered rules page and add a new rule, label "Send e-mail
  2. to publishers" and event "After saving new content" (we clone the rule later for updated content).
  3. Add a condition "Content has type" and select "Article".
  4. Add a condition "Field has value", select "field_workflow" and select "Reviewed" as Workflow.
  5. Add an action "Send a mail to all users of a role" and select "Publisher" as role.
  6. Enter a subject like "'[node:title]' has been reviewed" and a message like "Content has been marked as reviewed. Link: [node:site-url]/node/[node:nid]".
  7. Got to the triggered rules page, clone the new rule and change the event to "After updating existing content" (we also want to affect updated content).

Looking for support? Visit the Drupal.org forums, or join #drupal-support in IRC.