I have a location field for a user that is created via the Content Profile module.

How can I access that field in code for the logged in user? Is it something like $user->content_profile['location']

I can't seem to grab this info.


You'll have to load the content profile node into a variable first using content_profile_load.

This should work:

$user_profile = content_profile_load('profile', $user->uid);

That will return an object ($user_profile) that you can call the fields which you've set up. Use

echo '<pre>'.print_r($user_profile,1).'</pre>';

to see which fields are available.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.