Theming a Drupal User Profile is actually much easier than you think. Follow these few simple steps and you will be on your way to a fully customized user profile for your Drupal site.

This article assumes that you know how to theme a node, if not, first read Theming a node in Drupal...The Easy Way.

There are two main ways to get custom field into the user profile, content profile or using the core user profile that ships with Drupal. If you just want simple fields the core module is the way to go. For the sake of this article I will be using the core user profile module.

Using 6.x go to http://www.yoursite.com/admin/user/profile, there you can set up a couple of fields to your liking.

Next make a new document called user-profile.tpl.php similar to the node-custom.tpl.php this overrides the user-profile.tpl.php that is found in the core user module. The benefit being you won't be editing the core module file.

Once you have that file made copy this code into the document:

<pre><?php print_r($account)?></pre>



Also similar to the custom node override you are printing the field information that you just set up in the user profile.
Save the document and upload it to your server. Check out your account at http://www.yoursite.com/user
You will now see a print out similar to this.
Similar to the node override you will print the fields that you want. For example:

<?php print $account->profile_name ?>



That will print the field Name that you set up in the User Profile. Continue this until you have successfully printed all your fields then use css to position them to your hearts desire.

Soon I will post an article on theming an advanced user profile. Subscribe now to make sure you don't miss it.

Comments

user profile edit

Thanks for the great post. How would you modify the User - Edit page? Could you create a user-edit.tpl.php?

Should have read this first

i see, after actually reading your article, that you already know how to theme the parts of the user profile that I suggested. Themeing the the user edit page and actual account page may prove to be a bit more in depth. it probably takes some hard core drupal theme functions. This is just a guess. please keep your findings up to date here as well. I would love to see what you learn about this topic.

Cheers,

Casey (http://twitter.com/z3cka)

shameless plug: http://twistedpairwd.com

You don't have to be an

You don't have to be an expert or know all the coding languages. Just start with the basics and expand from there. Go buy a coding book or do research online. Search engines will be your new best friend with learning code. Try out the code, and if it doesn't work try to understand why it doesn't work. But you must remember point one, be patient. Don't get frustrated when something doesn't work the first time. There is always a reason why it doesn't work, take some time and trace the steps and you will come out with a solution.

thank u

thanking u for providing useful information. I really appreciate u bcoz u r providing very valuable information to us

keep providing like this information.

urs,
franklin

Post new comment

  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.

More information about formatting options