1

Is there any way to refine the user reference field values based on node references value. Let me explain : I have one node reference field and user reference field in one content type and another node reference is added to user profile fields. Both node reference are of same content type with different name. Is there any way to refine the view of user reference field based on node reference field value.

Image of User Profile

Image of Content type

1 Answer 1

1

If what you are asking is can you change the user reference field to something based upon a node reference field, sure, not a problem. But what do you want to change it to? If it's the user id of the creator of the node referenced, that's easy:

// load node in question
$node=node_load($nid); 
// load node referenced in that node
$node_referenced=node_load($node->field_node_reference[$node->language][0]['nid']);
// set user referenced in node to the uid of the node referenced in it
$node->field_user_reference[$node->language][0]['uid']=$node_referenced->uid;
// save the node
node_save($node);

If you want to do this automagically, you can look at hook_node_presave() and have this done every time a node type is saved.

1
  • thnx for give your timing frnd.. but i want to change the value on ajax call of change of node reference field value. by give an argument to the view of user reference field.. is there any way to pass argument to a view of user reference field.. Commented Jul 24, 2012 at 4:16

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.