I'm creating nodes using a custom modules
$node = new stdClass();
$node->type = $link['content_type'];
node_object_prepare($node);
$node->uid = $user->uid;
$node->name = $user->name;
$node->title = $html['title'];
$node->language = LANGUAGE_NONE;
$node->body[$node->language][0]['value'] = $html['html'];
$node->body[$node->language][0]['summary'] = $html['summary'];
$node->body[$node->language][0]['format'] = 'filtered_html';
$node->menu['enabled'] = 0; // 1 to enable providing a link in main menu
$node->menu['link_title'] = urlencode($html['title']);
$node->menu['description'] = urlencode($html['summary']);
$node->menu['parent'] = 'main-menu:0';
$node->menu['weight'] = 5;
$node->path['alias'] = urlencode($html['title']) . time();
$node->comment = 1;
$node->status = 1; // 1 means published
$node->promote = 0;
$node->revision = 0;
$node->changed = $_SERVER['REQUEST_TIME'];
$node->created = $_SERVER['REQUEST_TIME'];
node_submit($node);
@node_save($node);
$node->path['alias'] .= '+' . $node->nid;
node_submit($node);
@node_save($node);
db_update('node_revision')
->fields(array('uid' => $node->uid))
->condition('vid', $node->vid)
->execute();
But now I need to assign each node a I create a workbench section, so I tried doing this:
$node->workbench_access = array('66');
node_submit($node);
@node_save($node);
$node->path['alias'] .= '+' . $node->nid;
node_submit($node);
@node_save($node);
db_update('node_revision')
->fields(array('uid' => $node->uid))
->condition('vid', $node->vid)
->execute();
This add the workbench access id temporarily, but when the page is refreshed it doesn't apply it. Is there a way to assign a node to a workbench section using php?
I just installed this module for the first time today funnily enough, it looks good :-)
Having a look at the
workbench_access_node_insert()
function (in theworkbench_access.module
file) it looks like the node object key it's looking for isworkbench_access_id
, notworkbench_access
.Also you need to provide an access scheme (either
menu
ortaxonomy
depending on what access scheme you've chosen atadmin/config/workbench/access/settings
). I think your code should look a bit like this:That's untested but looking at the module file it should work.