Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
PLEASE NOTE! These snippets are user submitted. It is impossible to check them all, so please use at your own risk! For users who have setup drupal using an alternate database to the default (MYSQL), please note that the snippets may contain some database queries specific to MYSQL.
Description
This php snippet displays single-line textfields. If the user has not specified anything, it displays nothing
Dependencies: profile.module
Usage
- Using a text editor like NOTEPAD.EXE or an equivalent, copy and paste the code into your user_profile.tpl.php file
- Change the custom profile field name from
profile_city
used in the example below. (Tip: go to administer -->> settings -->> profile and in the second column it will give you the field name.) - Tested and works with Drupal 4.5 and 4.6
- Change the div class names or the prefix text to suit.
<?php if($account->profile_city): ?>
<div class="fields">City: <?php print check_plain($account->profile_city) ?></div>
<?php endif ?>
Comments
Shouldn't it
Shouldn't it be:
Or is the data sanitization performed elsewhere?
Hello, can anybody say me
Hello,
can anybody say me how this works with cck and drupal6 ? Thanks for any help.
best regards.
Change in Drupal 6
Hello Ariadoss,
In order to show custom fields added throgh Profile module, you have to replace $user variable with $account variable.
For example
changes to
Imran Khan
Project Manager
New Earth Marketing
Hmm not working for my 5.X
Hmm not working for my 5.X Site. I was trying to get a print_r of all the available fields and then hand pick what I wanted. How can we get a dump of all elements that can be displayed (Drupal 5)?
What about Content profile?
I can't extract the field from the content profile module, which I use instead the core one.