A basic User Profile Page to help get you started

Last modified: August 23, 2009 - 14:58

Please note: These snippets are user submitted. It is impossible to verify they all work as advertised, so please use at your own risk! Be advised that the snippets here may contain database queries specific to MySQL only.

Description
This php snippet displays is a basic user_profile.tpl.php file to help get you started.

Dependencies:
Requires the profile.module to be enabled and city, country custom single-line profile fields added.

Usage

  • Using a text editor copy and paste the code into user_profile.tpl.php file.
  • Change the custom profile field names to match the specific site. (Tip: go to administer -> settings -> profile and in the second column it will show the name of each field).
  • Change the div class names or the prefix text to suit.

<div class="custom_profiles">
<div class="fields"><?php print check_plain($account->name) ?></div>
<div class="fields">City: <?php print check_plain($account->profile_city) ?></div>
<div class="fields">Country: <?php print check_plain($account->profile_country) ?></div>
<div class="fields">Postcode: <?php print check_plain($account->profile_postcode) ?></div>
</div>

A starter template that reproduces a D5 profile

<div class="profile">
<?php if ($account->picture) { print theme('user_picture', $account); } ?>
  <?php foreach ($fields as $category => $items) {
    if (
strlen($category) > 0) { ?>

<h2 class="title"> <?php print check_plain($category); ?> </h2>
<?php } ?>
    <dl>
<?php
     
foreach ($items as $item) {
        if (isset(
$item['title'])) { ?>

        <dt class="<?php print ($item['class'].'">'. $item['title']); ?> </dt>
  <?php } ?>
    <dd class="<?php print ( $item['class'] .'">'. $item['value']); ?></dd>
<?php } ?>
     </dl>
<?php } ?>
</div>

Auto-configure a profile.

dman - February 17, 2008 - 05:56

For auto-configuration of a dozen common 'profile' fields, you may want to try vcard.module which now as a bonus has one-click creation of a default user profile definition with standard attribute names.
It's a handy shortcut. If you don't want vcard, you can disable it and remove after it's done the creation.

.dan.
How to troubleshoot Drupal | http://www.coders.co.nz/

Basic profile for Drupal 6

mr.andrey - December 19, 2008 - 20:59

Here's a simple profile that puts the user picture, history and location in a smaller right column and the rest on the main page:

<?php
$output
= array();
$output['right'] = array();
$output['main'] = array();

foreach (
$profile as $type => $data) {
  if (
$type == 'user_picture'
  
|| $type == 'locations'
  
|| $type == 'summary') {
   
$output['right'][] = $data;
  } else {
   
$output['main'][] = $data;
  }
}
?>


<?php // OUTPUT ----------------------------- ?>

<div class='profile'>
<table style='margin:0; padding:0; float:right; width:328px' width='328'>
  <tr>
    <td style='padding:0 0 0 25px'>
    <?php foreach($output['right'] as $data) { echo $data; } ?>
    </td>
  </tr>
  <tr>
    <td style='padding-left:30px'>
    </td>
  </tr>
</table>

<?php foreach($output['main'] as $data) { echo $data; } ?>

Missing </div>

kari.nies - October 26, 2009 - 18:46

Add to the end of this example to make it work properly.

default picture

Bacteria Man - January 10, 2009 - 22:05

If "Picture support" is enabled and a "Default picture" is defined, remove the condition around the "user_picture" theme function call otherwise the default picture will not display.

<?php print theme('user_picture', $account); ?>

-------------------------------------------------------

"If you don't read the newspaper you are uninformed;
if you do read the newspaper you are misinformed."
-- Mark Twain

 
 

Drupal is a registered trademark of Dries Buytaert.