I want to compare a term_reference field in a node with a term_reference field in a user profile. If certain terms match, I want to message the users with those matching terms. Is this something that could be achieved with rules?
EDIT: This is my code so far:
dpm($node->field_project_resources);
dpm($node->field_project_resources['und']['0']['tid']);
$users = entity_load('user');
$arrayuids = array_keys($users);
$query = new EntityFieldQuery();
$query->entityCondition('entity_type', 'profile2')
->propertyCondition('uid', $arrayuids, 'IN');
$profile = $query->execute();
$arrayofpids = array();
foreach($profile as $obj){
foreach($obj as $objinner)
{
array_push($arrayofpids, $objinner->pid);
}
}
$profile2s = profile2_load_multiple($arrayofpids, FALSE);
foreach($profile2s as $obj){dpm($obj);
foreach($obj as $objinner){
if(is_array($objinner)){
foreach($objinner as $i)
{dpm($i);
foreach($i as $n)
{
}
}}
}
}
I want to compare for each value in array field_project_resources result with the profile2 array field of field_resources for each user and then return an array of users that have matching fields. I am quite new to this and I would appreciate some help.