2

I want to achieve the following : I have a node 'proposal' with a flag 'accept' and another node 'project'. I want when a user flag the 'proposal' with the 'accept' flag, a field value in the 'project' node is updated. I wrote this code but it seems not to work

function mymodule_flag_flag($flag, $entity_id, $account, $flagging)
{   

$node =  node_load($entity_id);
$freelancer = $node-> uid;
$project_node = node_load($node->field_projet['und'][0]['target_id']);
$wrapper = entity_metadate_wrapper('node', $project_node);
$wrapper->field_freelancer->value = $freelancer;
}

1 Answer 1

0

I do not see that you are saving the project node, after changing field value.

function mymodule_flag_flag($flag, $entity_id, $account, $flagging) {     
  $node =  node_load($entity_id);
  $freelancer = $node-> uid;
  $project_node = node_load($node->field_projet['und'][0]['target_id']);
  $wrapper = entity_metadate_wrapper('node', $project_node);
  $wrapper->field_freelancer->set($freelancer);
  // You missed
  $wrapper->save();
}
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.