Last updated December 7, 2010. Created by scarer on November 2, 2010.
Log in to edit this page.

I needed to create a six monthly review for content to change the content to a different work state and to send an email to the author letting them know their content is due for review.

I accomplished this task using workflow and triggered rules.

Firstly I created a workflow that I applied to a list of content types. I added a state to this workflow called 'Due for review'. This state had an sid value of 7. So changed the sid value to whatever is appropriate for you. I created a new rule and scheduled it to occur on cron job events. Then I added a custom PHP script with the following code:

//get every node in the database that has been assigned a workflow
$result = db_query("SELECT n.nid, n.uid, n.changed, wn.sid FROM {node} n JOIN {workflow_node} wn ON n.nid = wn.nid");
$row = db_fetch_object($result))
$nid = $row->nid;
$changedate = $row->changed;
$sid = $row->sid;
$user = $row->uid;
//call function to see if notification should be sent
notify_author($nid, $changedate, $sid, $user);
//this function notifies the author if their node is due for updating
function notify_author($nid, $c, $sid, $u)
$changeddate = date("d/m/Y", $c);
$revdateone = strtotime("+6 months", $c);
$revdate = date("d/m/Y", $revdateone);
//current timestamp
$currentdate = date('d/m/Y');
//drupal_set_message('Changed date = ' . $changeddate);
  //drupal_set_message('Review date = ' . $revdate);
  //drupal_set_message('Current date = ' . $currentdate);
  //if review date is here and workflow state is not marked for review send email
if ($revdate <= $currentdate && $sid != '7')
//drupal_set_message('Current sid = ' . $sid . ' for node nid ' . $nid . 'Author uid = ' . $u);
//update workflow_node
$new_state = 7;
workflow_execute_transition($nid, $new_state);
//send email
sendemail($u, $nid);
//sends email to required user
function sendemail($u, $nid)
//drupal_set_message('Got to the send email function!');
$author = user_load($u);
$currentnode = node_load($nid);
$to = $author->mail;
$subject = "Your content is due for review!";
$body = "Hi,\n\nHow are you $author->name? Your content $currentnode->title is due for review!
Please log in and visit
$currentnode->nid to edit your node. When you've
finished editing your node please change the workflow to submit for review. The publications
moderator will review your content as soon as possible."
$headers = "From:\r\nReply-To:";
if (
mail($to, $subject, $body, $headers)) {
drupal_set_message("<p>Message successfully sent!</p>");
  } else {
drupal_set_message("<p>Message delivery failed...</p>");

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