How do I pull in the node->uid of a node? I am currently working on displaying a grid of vendors for a site, and I need to test each vendor to find out if they are a favorite of the currently logged in user. Not sure exactly how to do it, but I'm using the Custom Field PHP, with the following code:

<?
global $user;
$runsql= "SELECT rid FROM {user_relationships} WHERE rtid = '1' AND requestee_id = %d AND requester_id = %d";
$fave = db_query($runsql, $node->uid, $user->uid);
if (($fave === false) || (is_null($fave))) {
$star = 'something';
}
else
{ $star = 'somethingdifferent';
}

?>

The issue is that I can't pull in node->uid. Any help?

Comments

FergalMohan’s picture

You might need to call node_load first i.e.
$node = node_load($nid);
but be warned if you are previewing within Views it won't be set you need to test on the "real" view.