I have another "interesting" problem using Workbench Moderation. I'm using Workbench for workflow, along with Workbench Access, Workbench Moderation (7.x-1.3) and Workbench Moderation Notes on a new Drupal 7 site.
I have created a custom Approvers field on my content type that editors will use to select which approver should receive the notification email. This is a list field where the approver name is displayed for selection (the label) and the associated value (key) is the email address of the approver. The latter is to be used in a rule to send the email to the correct address. I have written some PHP to extract the value from the selected item in this Approvers list field:
<?php
$node_id = arg(1);
$node = node_load($node_id);
$fieldname='field_approvers';
$items = field_get_items('node', $node, $fieldname);
if($items)
{
$key = $items[0]['value'];
echo "key = ". $key;
}
else
{
echo $node_id;
}
?>
Note that this is inserted in a block for testing purposes and I am not very experienced in PHP (or Drupal for that matter!).
While testing, I have discovered that before publishing the node, all works well and I can extract the correct email address. However, similar to my issue yesterday (Workbench Moderation - Issues with New Drafts of Published Nodes), once a node is published and set back to draft, things stop working properly. The published value of the list field is always returned, even when the list field itself shows the correct new approver. So, if I set back to draft and change the approver in the list field, the PHP code will always return the value from the published version of the node. I have debugged the node and checked the database and the web and I can't figure out how to get the Approvers list field value from the current revision.