Hi, I add profile picture field of author in node displays with this code in code field:
<?php
if (isset($object->picture)) {
return theme('image', $object->picture);
}
?>
but, is possible add a field of my profile, "firstname" and "lastname" for example?
thanks
Comments
Comment #1
xtfer commentedI'll need a bit more information to help you. Are you trying to get firstname and lastname from a user profile, and if so what method are you using to create user profiles?
Comment #2
tecnosalva commentedI used the Drupal core module: profile, in admin/user/profile, I've got a category named "personal" and into I add two fields: "profile_firstname" and "profile_lastname".
I have tried with this code:
But this print the fistname the user logged, however I want to print the author name of the node. what is wrong?
Thank you for your help.
Comment #3
xtfer commentedThis is not Display Suite related - you should be able to find this sort of info pretty easily by googling for it or exploring drupal.org.
global $useralways returns you the current logged in user. You want to use the uid of the person who's profile you are trying to load. If you are on a page like/user/87then you can get it using the arg function. If you are on a node, use$node->uid.Comment #4
tecnosalva commentedI´m sorry but I am a bit clumsy programming in php, now I have tried this:
but does not work.
Thanks for your help anyway
Comment #5
xtfer commentedI havent tested this, but, profile_load_profile should work with ANYTHING that contains a uid key, so try...
Comment #6
rajatgusain commented@xtfer
profile_load_profile($node);
Above function will not work it needs the user object.
@tecnosalva,
Please make sure that $node is available and it contain the values of nodes.
Then use the following code :
$node_author_id = $node->uid;
$author_info = user_load($node_author_id);
Now $author_info is having all the data about the author.
if you are having the profile_firstname in the profile area then use following code to access author's firstname.
$author_info->profile_firstname;
Cheers :::::::
Rajat Gusain
Comment #7
xtfer commented@rajat
If you read the function, you will notice that, although its signature has a $user variable, it will accept any class with a uid key.
Comment #8
tecnosalva commented@rajatgusain @xtfer Thank you very very much for your help, now all is all right, I changed only $node for $object, would look like:
Comment #9
tecnosalva commented