I for the life of me cannot figure out what variables/strings to use to print any of the profile fields for the user-profile.tpl.php page. I have looked all over on Drupal and nobody has come up with the correct answer. What worked for Drupal 5 does not work for Drupal 6. When you create a user-profile.tpl.php page in the theme folder it is automatically detected and used. All I want to know is how to print the fields that are entered during the registration. It should be some simple code snippet that I have been searching for and can't figure out.

<div id="dont_know">First Name:
<?php print $dont_know['profile_first_name']; ?> </div>

Any help is greatly appreciated. I have tried to figure this thing out for two days and I don't know too much about figuring out which variables to use and which strings to use. Thanks!

Comments

kayaker’s picture

Have you looked at profile-listing.tpl.php in the Drupal API?

__________________________________________________________________________________

Aweigh - not all who wander are lost.

mracarpenter’s picture

Thanks kayaker for the fast response. I have read through that page and even copied the example snippet at the bottom and still no luck! I've tried different variations of strings and so on and nothing works. I've checked and re-checked my profile module to make sure there's no misspellings and made sure there was a value entered in for profile_first_name. I've even check the database tables in phpMyAdmin. If you think you can figure it out let me know. I know a lot of other people have asked the same questions I am and can't seem to get it figured out. Thanks.

kayaker’s picture

The snippet didn't work for me either. After some wandering about I found the $account variable.

Using this snippet

<?php print '<pre>'. check_plain(print_r($account, 1)) .'</pre>'; ?>

in your user-profile.tpl.php file will reveal the contents of $account.

Within that content, I found the user-defined profile fields (profile_my_field, etc.) as well as all of the standard profile information.

As usual, I have no idea if this is the Drupalesque way of doing things.
__________________________________________________________________________________

Aweigh - not all who wander are lost.

mracarpenter’s picture

Thanks for the help. How do I go about printing the first name if it's [profile_first_name]? I still can't get it to print. I tried:

<?php print $profile['profile_first_name']; ?>
<?php print $profile['profile_first_name']->value; ?>

and it still will not show the first name! This is a rediculous nightmare. I feel like I'm missing some simple thing. Please bear with me. Thanks.

kayaker’s picture

This is a rediculous nightmare.

Been there, done that, no t-shirt.

$account is an object (note: I'm using $account not $profile).

<?php print $account->profile_first_name; ?>

__________________________________________________________________________________

Aweigh - not all who wander are lost.

mracarpenter’s picture

Success! Thanks a lot. I've been trying to customize the profile pages for a while. It's like I've waken from my horrible nightmare...

popetardo’s picture

Is this variable available in page-user.tpl.php file?

I'm trying to insert a google map taking some profile values. Google need to load a javascript on an onload event. I inserted it in page-user but don't work.

Thank's

Ok, it's done.

I inserted this code in user-profile.tpl.php file:

<div id="map" style="width: 500px; height: 300px">
<?php echo '
    <script src="http://maps.google.com/maps?file=api&amp;v=2&amp;key=YOURPRIVATEKEY" type="text/javascript"></script>
    <script type="text/javascript">
    //<![CDATA[
      if (GBrowserIsCompatible()) {
        var map = new GMap2(document.getElementById("map"));
        map.addControl(new GLargeMapControl());
        map.addControl(new GMapTypeControl());
        var gc = new GClientGeocoder();
        str="';
print str_replace(","," ",$account->profile_street).",".$account->profile_town.",".$account->profile_city.",".$account->profile_country;
echo '"
        str=str.replace (/\(.*\)/g,"");
        str=str.replace (/nº/g," ");
        str=str.replace (/º/g," ");
        str=str.replace (/ª/g," ");
        gc.getLocations (
                str,
                function (response) {
                        if (!response || response.Status.code != 200) {
                                alert("No se encontró la dirección "+str);
                        }
                        else {
                                place = response.Placemark[0];
                                point = new GLatLng(place.Point.coordinates[1], place.Point.coordinates[0]);
                                map.setCenter(point, 15);
                                var marker = new GMarker(point);
                                map.addOverlay(marker);
                                str=place.address
                                str2=str.replace (/, /g,"<br>");
                                str=str2.replace (/Spain$/g,"España");
                                if (place.AddressDetails.Accuracy > 7) {
                                        marker.openInfoWindowHtml("<font face=Arial size=2>"+str+"</font>")
                                }
                                else {
                                        marker.openInfoWindowHtml("<font face=Arial size=2>La ubicación en el mapa es aproximada&nbsp;&nbsp;&bsp;<br>"+str+"</font>")
                                }
                        }
                }
        );
      }
    //]]>
    </script>
';
?>
</div>
gerardodsg’s picture

I commited the stupidity to update to drupal 6 a site that i made with some heavy profile displaying and i didn't research about it because i'm not exactly an experienced developer (i'm a graphic designer and just getting into this). You just save me some bitternes.

Therefore i thank you so much!

miahawk’s picture

this is exactly the info I needed to customize my user profiles!

JonathanHindi’s picture

I tried to use it to print profile_first_name in a block title using block.tpl.php

 global $account;
if($block->subject == 'User Menu') {
$block->subject = 'Welcome ' .  $account->profile_first_name;
} 

It doesn't work i dunno why ?

it prints welcome and nothing beside welcome.

Please Help
Thanks

dzescsd’s picture

Hi,

Have you found a solution to print the data profile_first_name in a block ?

Thanks

janis_lv’s picture

want to achieve the same :[
print a profile field into navigation menu