Hey all,

I'm trying to create a rule that executes when a node of a certain content type is created.
The rule must get the selected taxonomy terms of the created node, and create a new node for each term.
The problem is that i can't get the taxonomy values to loop and create, and use their names as titles.

foreach ($node->taxonomy as $tid) {
$newnode = new stdClass();
$newnode->title = $tid->name.'_node';
global $user;
$newnode->uid = $user->uid;
$newnode->name = $user->name;
$newnode->type = 'mytype';
$newnode = node_submit( $newnode );
node_save( $newnode );
}

No matter how many taxonomy terms I select for the created node, the code is creating only one new node with only _node as title.

Any advice is appreciated, thanks in advance.

Comments

rabihs’s picture

Solved, just needed to add
$node = node_load($node->nid);
on top

rabihs’s picture

Status: Active » Closed (fixed)
mitchell’s picture

Component: Miscellaneous » Rules Core

Updated component.