Retrieving the Node Id of the profile of the current user

Events happening in the community are now at Drupal community events on www.drupal.org.
davidzo's picture

I am working with Rules and I can't figure out what code I need to enter into the PHP code box so that it will return the NID of the profile node for the currently logged in user.

I think this is just a matter of knowing which variable hold the value but I can't find it anywhere.

Comments

You can figure out the UID

davidzo's picture

You can figure out the UID using

return array(0=> array('uid' => $user->uid));

But how do you get the profile's NID using the user's UID?

Depends

niklp's picture

What method are you using to provide the user with a profile? Content_profile module, or something else? What version of Drupal?

Web Development in Nottingham, UK by Kineta Systems / Follow me on Twitter! @NikLP

me too

ublanke's picture

Hi,
I got the same issue. I want to create an own template with user-profile.tpl.php and I need to access the corresponding node (nid) from the uid.

using drupal 6 and the content node module. (no additional plugins used for the user profiling)

cheers,
ulf

Hi. You can use the

gabocas's picture

Hi. You can use the method:

content_profile_load('perfil', $uid, $lang = '')

Where 'perfil' is the content_type of the profile content, $uid is the user id fetched previously and $lang = '' is a parameter that you can keep equal.

I hope this can Help!

Regards,

Gabriel

Sometimes you need to set the $user to get uid

pvanerk's picture

global $user;
$user_profile_node = content_profile_load('profile', $user->uid);
return $user_profile_node->nid;

Profiles as nodes

Group organizers

Group notifications

This group offers an RSS feed. Or subscribe to these personalized, sitewide feeds: