I'm using Workbench Moderation module because it matches my needs. I have a front-end form that initiate the node with some fields. Editor should review the node and fill all the required fields remaining.
So, I need to make sure that all fields are now filled with data then the state should be changed to Needs Review.
I implemented hook_workbench_moderation_transition to trigger the state change. If the next state was Needs Review, then I would make sure that all required fields were filled with data otherwise I would change the state back to the previous one and redirect to the node edit form.
What I've done so far
function workflow_handler_workbench_moderation_transition($node, $previous_state, $new_state){
if ($new_state == 'needs review'){
//check if node was not reviewed before , then redirect to form
$instatnces = field_info_instances('node',$node->type);
//should check first if conditional_fields module is existed
$CFS = conditional_fields_load_dependencies('node',$node->type);
foreach ($instatnces as $key => $field_options) {
$field = field_get_items('node', $node, $key);
if ($field_options['required'] && !$field && !array_key_exists($key, $CFS['dependents'])) {
//set workbench state to previous one
workbench_moderation_moderate($node, $previous_state);
drupal_set_message(t('Please make sure that all required fields has been reviewed'),'error');
$url = url("node/$node->nid/edit");
header("Location:$url");
drupal_exit();
}
}
}
}
Problem exists when using workbench_moderation_moderate in the context above. For some reason, when I got redirected to the form to edit, and after saving, my edits were not saved on the node object and so if I opened the edit form again, I couldn't find my edits. Any ideas?