Download & Extend

Change viewers/editors programatically (node_save)

Project:Coherent Access
Version:6.x-1.x-dev
Component:Code
Category:support request
Priority:normal
Assigned:Unassigned
Status:closed (fixed)

Issue Summary

Hallo,
For my project, I have the following setup:
- a content type party (and coherent access as enabled, default is not private)
- a cck userreference party host.

I build a batch import form with some values that automatically create the title. In my submit function a use emtpy $node object to store all the needed values like $node->title, etc. and then save it with node_save($node);
WORKS
But how do I set the coherent_access viewers? I tried:

$node->coherent_access['private'] = 1;
$node->coherent_access['viewers'][23] = "userx";

But the values are not saved after node_save.

Any hints?

Comments

#1

Version:5.x-1.1» 6.x-1.x-dev

#2

It should work if you set the following to a serialized array of usernames keyed by uid.

$node->shared_editing['edit']['editor_list']
$node->shared_editing['view']['viewer_list']

So to use your example:

$viewers = array(23 => 'userx');
$node->shared_editing['view']['viewer_list'] = serialize($viewers);

#3

Status:active» closed (fixed)

Marking this as fixed.