[support] Saving a node with drupal_execute - changing node's owner
Victor Kane
victorkane at gmail.com
Tue May 29 11:18:31 UTC 2007
Here is a snippet that has worked for me, but by transforming the array into
an object and then performing node_submit() and node_save():
...
$node = (object)$node;
$node = node_submit($node);
node_save($node);
and the following snippet I know for sure correctly saves the uid:
$section_node = new stdClass();
$section_node->title = $org_name;
...
$section_node->uid = $account->uid;
$section_node = node_submit($section_node);
node_save($section_node);
Victor Kane
http://awebfactory.com.ar
On 5/29/07, Zohar Stolar <z.stolar at gmail.com> wrote:
>
> I'm using drupal_execute() to save a CCK node.
>
> I'm trying to save the node on behalf of a different user (different
> than the current user).
>
> However, I don't manage to set the ownership of the node.
>
>
> Was anyone able to do such a thing? This is how I try to do it:
>
>
> $title = 'The node's ';
>
> $name = 'usernameA'; // the owner ti be, not the current user
>
> $uid = 23; // the user's uid
>
> $node = array('type' => 'article', 'uid'=>$uid,'name'=>'$name');
>
> drupal_execute('organization_node_form',array('title'=>$title,'op'=>'submit'),$node);
>
>
> What I get is a node with an anonymous owner...
>
>
> Thanks,
> Zohar
> --
> [ Drupal support list | http://lists.drupal.org/ ]
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.drupal.org/pipermail/support/attachments/20070529/d999e12b/attachment.htm
More information about the support
mailing list