Reputation: 163
I've created a module to edit node content automatically. And the site is using the "Workbench Moderation" module.
But I can't figure out how to get the node to duplicate into a new revision (in "draft" status). My edited content always appears in the "published" version of the node.
Does anyone know what the API calls should be to make this happen?
Upvotes: 6
Views: 3051
Reputation: 106
I was just having this issue myself. Key things:
Drupal takes care of the rest.
<?php
$node = node_load($nid);
$node->body[LANGUAGE_NONE][0]['value'] = 'My new body content';
// We're wanting drupal to create a new revision
$node->revision = 1;
// We want workbench moderation to treat the new revision as a new draft
$node->workbench_moderation_state_new = workbench_moderation_state_none();
node_save($node);
This is currently working in my codebase.
Upvotes: 7