How to create a “project” programmatically using Drupal Workbench Moderation?

I created a module for editing node content automatically. And the site uses the "Workbench Moderation" module.

But I can’t figure out how to get node to duplicate the new edition (in draft status). My edited content always appears in the "published" version of node.

Does anyone know what API calls should make this happen?

+6
source share
1 answer

I had this problem myself. Key things:

  • Content type is in moderation through Workbench moderation module
  • Set a new moderation status
  • Set node as a new revision

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 currently works in my codebase.

+7
source

Source: https://habr.com/ru/post/974564/


All Articles