By farald on
I want to use a single custom user profile field in the nodetempalte with drupal ver 5x.
<?php print $user->profile_websiteurl ?>
This doesn't work. Do I have to call mysql to make it work?
In that case, how do I make the call?
Comments
You need to the load the profile information
To make your code work try:
Put this at the top of the page - then you can access profile variables. Profile_load_profile is a function in the profile module.
Alex Pott
Thanks a lot!
Thank you, it worked like a charm:D
Erm..no.
Worked with test-user, until I logged out:D
Problem:
I wanted to get the node author's profile info, not the currently logged-in user:)
Is there a simple way to do this?
try this
try this
the $owner object is now a user object for the node's owner (author).
EDIT: the uid in $node->uid may be wrong...I'm going off of memory right now...it might be $node->owner or $node->user if $node->uid doesn't pick up the right value for the node author's user id.
Lead Developer and Founder of StreamRiot.com
didn't work
I tried adding this to contemplate:
It did not work, outputs nothing.
I need this for adding a js tab to articles containing various author contact information.
Any suggestions?
user_load
$owner = user_load(array('uid'=>$node->uid));Has to be an array. Explained here:
http://drupal.org/node/46317#comment-87228
That's for pulling user info into nodes. For comments:
$owner = user_load(array('uid'=>$comment->uid));User profile:
$owner = user_load(array('uid'=>$user->uid));Thank you
Thank you so much for this, raponec, it solved 90% of my related problems! Thank you!
The only thing not working now is a date field in the profile. It outputs "array".
Thanks again! :)
That's because the variable is an array
Use print_r() to dump the array into your content with all of its elements
print_r ($owner->profile_startdate,true);- then alter your code to print the desired element maybe something like (I don't know the array structure of the date field in the profile module)
print $owner->profile_startdate['value'];If you have the devel module installed (which I would recommend) then you can use the dpm() command to dump variable to drupal's message system.
So for example
dpm($owner);would dump the entire owner object - can be very useful.
Alex Pott