Handling checkbox 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 illustrates how to use custom User Profile checkbox Fields.

Dependencies: profile.module

Usage

  • For use in your user profile page override
  • Using a text editor like NOTEPAD.EXE or an equivalent, copy and paste the code into your user_profile.tpl.php file
  • In the example snippet we used a custom checkbox for "Click if you're a MAC user" and called the form name profile_mac
  • Tested and works with Drupal 4.5 and 4.6
  • Change the div class names or the prefix text to suit.

<div class="fields">
<?php if ($account->profile_mac == '1') {print "I use a mac" ;}; ?>
<?php if ($account->profile_mac == '0') {print "I do not use a mac" ;}; ?>
</div>

Check box Validate

khan2ims - January 12, 2009 - 16:16

Use www.drupal.org/project/checkbox_validate if you need to validate whether one of the check box is selected or not.

Is very necessary for I agree check box.

It also works for content types

 
 

Drupal is a registered trademark of Dries Buytaert.