0

I have users and nodes. bith have the same term referende field:

field_area

goal is to display a message in node.tpl.php when: - user has term 'south' - node has term 'south'

i have used the field extract module to get id term ID from the node. $tid_node = field_extract_value('node', $node, 'field_bedrijf', 0, array('key' => 'tid')); term id is .e.g: 5

Now i would like to find the term id using the user->field_area field.

I would utlimately have a code like:

if $tid_node == $tid_user {
print "a custom message" ;}
0

Found the solution after seaching around. node term id:

$node_tid = field_extract_value('node', $node, 'field_your_taxonomy_reference_field', 0, array('key' => 'tid'));  

user term id:

//load current user    
$user_info = user_load($user->uid);
$user_term_id = $user_your_taxonomy_reference_field['und'][0]['tid']; 

now set logic if ($node_tid == $user_term_id) { print "show link"; }

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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