Get term value from user field and set that value to new field How to get term from user field and set that to the field in node?
When user is creating node I need to get term and set it to the node field.

I have field_term_reference in user fields and in node I have field_book_reference field. I need to get term from field_term_reference and set that term to the field_book_reference.

Both fields has autocomplete widget.

Here is my current non-working code:

function set_value_node_presave($node) {
global $user;
$user = user_load($user-&gt;uid);
$term = field_get_items($user, $account, 'field_term_reference');

$node-&gt;field_book_reference[$node-&gt;language][0]['value'] = $node-&gt;$term;

}


SOLVED Here is working code:

function set_value_node_presave($node) {
global $user;
$user = user_load($user-&gt;uid);
// Get field from user
$term = field_get_items('user', $user, 'field_term_reference');

$node-&gt;field_book_reference[$node-&gt;language][0]['tid'] = $term[0]['tid'];

}
$node-&gt;$term definitely isn't what you want. Taxonomy references are stored by tid, so

$node-&gt;field_book_reference[$node-&gt;language][0]['tid'] = $term[0]['tid'];


should work