I am attempting to have a user's name appear on the bottom of the user's profile picture. Can anyone let me know what the php code is for that? I have checked the "Evaluate text as PHP code" box, and tried a few different values but have had no success as of yet. Note, my server currently is suffering from "Low Quality / Poor Performance GD Image Filtering" so perhaps this is part of the problem, but I was hoping to find out what the correct php code should be to print out the user's name on the image.
Thanks

Comments

dman’s picture

Return $node->name;

?

allandk’s picture

Return $node->name;
or
Return $user->name;

not working :-(

dman’s picture

Assuming that the image in question was actually owned by - attached to - a node, and that a user owned the node, that should be working.
How are you attaching your images and assigning ownership?
Can you try putting

drupal_set_message(print_r(get_defined_vars(),1));

into the code area and seeing what values are available?

allandk’s picture

the images are cck file field in a node called user images

allandk’s picture

$user = db_fetch_object(db_query('SELECT name FROM {users} WHERE uid = %d', $node->uid));
return $user->name;

i dont understand why this is not working ???

dman’s picture

I would expect that code to work - yes.
Were you able to confirm that the $node was being loaded correctly in the first place? The algorithm that goes from filepath->file->filefield->node can be unreliable due to occasional changes in the CCK DB schema.

fietserwin’s picture

Status: Active » Closed (cannot reproduce)

The 6.x-2.x is not supported anymore and we are closing all issues for it. Please feel free to reopen against the 7.x-1.x branch if the error still appears there.