I fight with the following: when an anonymous user creates a node and saves it a product is added to the cart. When this user goes to checkout, he can choose username and password on his own or a new account is created. My problem: when he finishes payments I found the following way to change some things on the originally created node of this customer using conditional actions and the following code:

if (isset($order)) {
  foreach ($order->products as $product) {
    if (isset($product->data['node_checkout_nid'])) {
      $node = node_load($product->data['node_checkout_nid']);
      $node->field_status['0']['value'] = 1;
      $node->field_orderid['0']['value'] = $order->order_id;
      node_save($node);
    }
  }
}

Found here: http://drupaleasy.com/blogs/ultimike/2009/03/event-registration-ubercart

Here I would like to add adtionally the name of the new user account to the node/ the user ID of the customer as the authors ID to the node. Has anyone an idea, how I can do this?

Comments

tobiberlin’s picture

Status: Active » Fixed

hi,

I found the sollution:

$node->uid = $account->uid;

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

fletch11’s picture

Thanks a lot - I was trying to figure this out for a while - can't believe it's so simple. Really useful if you have a classified type system and want to enable anonymous users to post stuff but then be able to edit in the future.