My content type (house) has an input field for email (this is not the logged in user) -- the intent is to use the email to get the UID so that I can pull his content profile information using Views. Using node reference or user reference proves challenging for the end user, since they may not know the username for user-reference or there may be duplicate titles for node reference (two people with the same name). They will however, always know the email address of the person they are referencing.
Thus I need to take the email address -> look up the corresponding UID -> and return the UID(s) so that I can use it as an argument in a block view. I should note that there can be multiple email value inputs (several referenced users/uids)
I've come up with the following-- which doesn't work-- I don't know if I'm on the right track or even where and how to implement it. Should this be a function somewhere - how do I do that?
foreach ($node->field_email as $i) {
$value = $i['value'];
}
$result = @db_query('SELECT uid FROM {users} WHERE mail = $value');
if (is_numeric($result)) {
return $user_ref;
}and then in my node-house.tpl file place:
print views_embed_view('user_refer', 'block_1', $user_ref);