Handling single-line profile fields
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_cityused 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($user->profile_city): ?>
<div class="fields">City: <?php print $user->profile_city ?></div>
<?php endif ?>
Shouldn't it
Shouldn't it be:
<?php if($user->profile_city): ?><div class="fields">City: <?php print check_plain($user->profile_city) ?></div>
<?php endif ?>
Or is the data sanitization performed elsewhere?