I'm using Drupal 7.9 for an internal website. I'm trying to customize the "user-profile.tpl.php" file so it shows the fields that I've customized in the "admin/config/people/accounts/fields" to be shown below:

<<>>image block on the left<<>>

"Full Name
Job Title/Position

Your Organization Name Here, INC
1234 Your Address Here
Long City Name, ST 12345

(P) 555-123-1234
(E) [email protected]"

But I'm having an issue writing the PHP in the "user-profile.tpl.php" file (I didn't touch the user-profile-category.tpl.php or the user-profile-item.tpl.php files)

This is what I've coded, which obviously is printing everything out wrong.

<div class="profile" style="float:left; width:100%;">

<div class="profile-image" style="width:20%; float:left;">
    <?php if ($user_picture): ?>
      <div class="user-picture">
        <?php print $user_picture; ?>
    <?php endif; ?>

<div class="profile-info" style="width:80%; float:left;">
    <h1><?php print render($user_profile['field_profile_full_name']) ?></h1>
    <p><?php print render($user_profile['field_profile_job_title']) ?></p>

    <h3><?php print render($user_profile['field_profile_organization']) ?></h3>
    <p><?php print render($user_profile['field_profile_address']) ?><p>
    <p><?php print render($user_profile['field_profile_city']) ?>, <?php print render($user_profile['field_profile_state']) ?> <?php print render($user_profile['field_profile_zip_code']) ?></p>

    <h3>(P)<?php print render($user_profile['field_profile_business_phone']) ?></h3>
    <h3>(E)<?php print render($user_profile['field_profile_e_mail_address']) ?></h3>



When it prints on the page, everything still has a bunch of page breaks and space in between the info. And the address line isn't included in one block, it puts it on a new line each item.

How do I write the code so I can get the format outlined above?

  • 1
    just use views module. in views you have more control over the UI without touching PHP or CSS
    – Aboodred1
    May 15, 2013 at 20:55
  • Thanks I created it as a block and put it on the user, and users/* pages only. I didn't think I could over-ride the users page since it was part of the template. May 16, 2013 at 15:43
  • Now how do I get rid of the User Template information that is being printed onto the user's page? I tried to delete the information in the user-profile.tpl.php file, but it still printed the fields out. Any suggestions? May 16, 2013 at 15:54
  • Adding style="display:none;" to the <div class="profile"> in the user-profile.tpl.php file seems to have fixed it. May 16, 2013 at 16:14
  • why you created it as block? you can create page view and use the same url to point to user profile page
    – Aboodred1
    May 16, 2013 at 16:34

2 Answers 2


You can utilize views module to achieve what are you looking for, with some CSS styles.

While using views you have two options view user information:

Option 1:

  1. Create block view (Users)
  2. Select user fields you want to display
  3. Then add Contextual filters (User: Uid)
  4. From the configuration page make sure to select Provide default value
  5. Then from Type drop down menu select User ID from logged in user.
  6. Then apply changes.
  7. Save view.
  8. Under Structure -> Blocks locate the new created view in content region
  9. Configure the block to appear only on the user account page user and users/*
  10. Then you need to clear the original drupal content in the user view account page by apply this custom module.


function mymodule_menu_alter(&$items){
  $items['user/%user']['page callback'] = 'mymodule_user_view_page';

function mymodule_user_view_page() {
  return array();

Option 2:

  1. Create page view (Users)
  2. Apply steps 2-6 as Option 1
  3. Add Path user/%user under Page Settings
  4. Save view.
  • Your step #5, says to "Then from Type drop down menu select User ID from logged in user." That only allows the Information for the currently logged in user to show on a page that doesn't belong to that user. Say for instance I want to look up User X so I type in users/User-X. But the information that appears is my information because I'm the one logged in. I tried to change the Contextual Filter to "User ID from URL" but that didn't seem to work. Any ideas on how to get this to work? May 17, 2013 at 15:46
  • @AmandaGray In your case you need to add another block in the same view and change Type to User ID from URL and make sure to locate the new block to on the following page users/*
    – Aboodred1
    May 17, 2013 at 18:24
  • Thank you Aboodred1! This works exactly how I want it to! May 17, 2013 at 20:09
  • @AmandaGray Glad it worked for you :)
    – Aboodred1
    May 17, 2013 at 20:13

This seems working.

However there is a issue regarding this implementation.

Users registered after creating this view block are not able to see any detail in My profile page.

Only the users registered before creating this block view are able to see their profile page .

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.