Extracting values from a user's profile
Hi
I am attempting to customise the appearance of a user's profile, when viewed. To do this, I have started by copying user-profile.tpl.php into my theme's active folder. When I put the command
<?php
print_r($profile);
?>Array ([user_picture] =>
[Personal] =>
Personal
Education
i am a great guy
[content_profile] => [summary] =>
History
Member for
23 hours 16 min
)
I understand that $profile is an array. What I am trying to do is work out how to print out individual values from the array, so that I can apply my own formatting to them. For example, in my test example, the value in the education field for this test profile is "i am a great guy". I've tried accessing this using commands like
print $profile['user_picture']['Personal'];
print $profile['user_picture']['Personal']['Education'];
print $profile['Personal']['Education'];
But none are outputting anything.
Any assistance would be a great help

This [Personal] => Some
This
[Personal] => Some Value</a> represents a keyed value pair, in this case 'Personal' is the key. So in general terms you want to use <code>print $value['key'];and in this case specifically you wantprint $profile['Personal'];.Thanks nevets for the
Thanks nevets for the reply.
The print $profile['Personal'] gives me the whole of the "Personal" category ("Personal" is a category in the user's profile and "Education" is one of the fields within that category). print $profile['Personal'] outputs the following:
"Personal
Education
i am a great guy"
Is there a way I can get just at the education field? i.e. the output needs to just be "i am a great guy"
Here is how I do it on one of
Here is how I do it on one of my sites.
I have a profile field in the category Personal Information that has the machine readable name as profile_location. Then I have a block which displays on the user profile page that uses this php.
<?phpglobal $user;
$userId = $user->uid;
profile_load_profile($user);
$theLocation = $user->{profile_location};
//code continues for other profile information I want to grab
?>
When I want to print out the users location I just say
<?phpprint $theLocation;
?>
That works perfectly! Thanks
That works perfectly! Thanks a lot ;)