Q:

Check if entity reference field (user) contains current user

I have a node page of Project content type which contains a multiselect enitity reference field of user type called field_team. I also have a block created by my custom module which is displayed at Project type pages only. What i'm trying to achieve is to do smth like this:
if ($current_node->field_team contains $current_user->uid) {
$output = 'some_specific_content'; 
} else {
$output = 'you are not a team member of this project';
}

How can I check if currently viewed node contains current user in its reference field?
Will be very thankful for any help or advice.

A:

Check following code:
global $user;
$team_members = array();
foreach($current_node->field_team['und'] as $team){
$team_members[] = $team['target_id'];
}

if (in_array($user->uid, $team_members)) {
$output = 'some_specific_content'; 
} else {
$output = 'you are not a team member of this project';
}

