Community Documentation

Handling checkbox profile fields

Last updated October 18, 2011. Created by John Morahan on January 22, 2006.
Edited by MGParisi, ronald_istos, Dublin Drupaller. Log in to edit this page.

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>

About this page

Drupal version
Drupal 4.5.x or older, Drupal 4.6.x, Drupal 4.7.x
Audience
Themers

Archive

Drupal’s online documentation is © 2000-2012 by the individual contributors and can be used in accordance with the Creative Commons License, Attribution-ShareAlike 2.0. PHP code is distributed under the GNU General Public License. Comments on documentation pages are used to improve content and then deleted.
nobody click here