I'm not sure if this is the right place for this question.
I'm using Node Profile to create a custom user account page.
I want to print the first and last names of users on a different page.
I've named the fields field_last_name and field_first_name.
So I'd like to:
print $field_first_name . " " . $field_last_name;
But I don't know how to access those two variables.
I know I can access user's User name and Id using

global $user;
print $user->name . $user->id;

Thank you for any help you can give me.

Comments

Mark Theunissen’s picture

The fields should be under $node, so for example $node->field_first_name

They are stored as arrays.

You'll have to do a node_load first, if you're not currently displaying the appropriate node.

Use the var_dump function in your code to take a look at the contents of a variable and find what you want:

$node = node_load($nid);
var_dump($node);

You'll have to find the $nid that is tied to the relevant user... and for that I guess you'll have to look at how Node Profile relates users and nodes...

Hope that helps!

__________________________________________________________

Mark Theunissen

Code Baboon
Drupal based services

Mark Theunissen’s picture

Have you considered using the Views module for this purpose?

__________________________________________________________

Mark Theunissen

Code Baboon
Drupal based services

Niaina’s picture

me too, i have the same prblm and i have used the view, it work well but i want is a Php code so that i can print it inside my page or story or somewhere else!

So if you have idea, thanks alot!

Niaina

ju’s picture

You should use function
nodeprofile_load($type, $uid)

for example

global $user;
$profilenode = nodeprofile_load('my_profiletype', $user->uid);
print $user->name . '  ' . $profilenode->field_last_name[0]['view'];

Julia

Niaina’s picture

I use the code that you give Julia and it going on well!

Thank you verry much indeed!

Niaina

gabocas’s picture

Hi!

Can anybody help me telling me what is the equivalent function to nodeprofile_load (valid for the module node profile) for the module content profile?

Thanks in advance,

Gabriel