Update workbench moderation state programmatically

Public

This updates (publishes) all nodes of given node type - use with caution

Get raw version
php
  1. $sql = "SELECT nid FROM {node} WHERE type = :type";
  2. $q = db_query($sql, array(':type' => NODE_TYPE))->fetchAll();
  3. foreach($q as $nids){
  4. $node = node_load($nids->nid);
  5. workbench_moderation_moderate($node, 'published');
  6. drupal_set_message(t("Updated: $node->title"));
  7. }