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
Comment #1
rabihs commentedSolved, just needed to add
$node = node_load($node->nid);on top
Comment #2
rabihs commentedComment #3
mitchell commentedUpdated component.