Q: How do I get the user id that is associated with a Content Profile node, it doesn't seem to have any obvious referenced user field?
A: The user that a Content Profile node refers to is given by the node's author field! It can be accessed as $node->uid
This one had me scratching my head for a while, the answer when you think about it is kind of obvious and was staring me in the face all along...
I found the answer here: http://groups.drupal.org/node/25478 (thanks alex.k!)
It seems that when a Content Profile node is created for a user, its uid field will always reference that user, even if another user actually created the profile node.
So to load up a user object from a Content Profile node you could do something like this:
$user = user_load($profile_node->uid);
If you're wondering how to do the opposite, that is load a content profile node for a given user/uid then have a look at this earlier post:
http://www.pridedesign.ie/content/drupal-content-profile-node-uid
Post new comment