Handling URL profile fields
Last modified: August 3, 2008 - 12:54
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 custom User Profile URL fields. If the user has not specified any link, 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 URL field name. In the example that is currently
$urlfieldname='profile_weburl'(Tip: go to administer -->> settings -->> profile and in the second column it will give you the name of the URL field.) - If you are using this snippet more than once in the same user_profile.tpl.php file add a number to the end of the $urlfieldname each time you copy the snippet. e.g. $fieldname1, $fieldname2, $fieldname3 etc.
- Change the div class names or the link prefix text to suit.
<?php $urlfieldname='profile_weburl' ;?>
<div class="fields">
<?php if($user->$urlfieldname): ?>
Website URL: <a href="<?php print check_url($user->$urlfieldname) ?>"><?php print check_url($user->$urlfieldname) ?></a>
<?php endif; ?>
</div>