Community Documentation

HowTo: Add a Terms of Agreement on Registration Page

Last updated November 27, 2009. Created by will.gresham on January 24, 2007.
Edited by regisit, bekasu, VM, slip. Log in to edit this page.

This is a quick and easy way to have users agree to a terms of service during registration using the profile.module. Ensure that the profile.module (part of core) is enabled, before beginning this recipe. Those looking for a module that does something similar should look to the legal.module. The "Terms of Use" module is another option.

Using Drupal 6.x:
______________________________

NOTE: See this node: http://drupal.org/node/179932 and look at #92 comment with a patch that fixes checkbox validation. Without this patch this trick does not work. This bug is present at in versions least up to 6.14. If you're not comfortable appying a core patch, use a contributed module as noted above or apply the following module to fix the core: http://drupal.org/project/checkbox_validate

Go to (administer > profiles)
Add a "checkbox" field, by clicking on the checkbox link under Add new field.

Now you are presented with a form, for the new profile field.
Fill out the form as follows (wording can be changed to suit your own use case)

Category: Terms Of Service (This will be the category under which the terms of service will be shown on the registration page)

Title: I Agree (Title of the checkbox itself)

Form Name: profile_tos (The field the checkbox will occupy in the database)

Explanation:
Here you can list your Terms of Service that should be read over, before checkmarking the checkbox. or you could create a node for the Terms of Service and link to that node in this field.

Weight: Set as you wish

Visibility: Private field, content only available to privileged users.

Page title: Leave Blank

Now all you have to do is check mark the checkboxes at the bottom of page titled:
The user must enter a value & Visible in user registration form.

-----Submit Form-----

Now visit the new registration form to see what's been created! : )






Using Drupal 5.x:
______________________________

Go to (administer > profiles)
Add a "checkbox" field, by clicking on the checkbox link under Add new field.

Now you are presented with a form, for the new profile field.
Fill out the form as follows (wording can be changed to suit your own use case)

Category: Terms of Service (This will be the category under which the terms of service will be shown on the registration page)

Title: I Agree (Title of the checkbox itself)

Form Name: profile_tos (The field the checkbox will occupy in the database)

Explanation:
Here you can list your Terms of Service that should be read over, before checkmarking the checkbox. or you could create a node for the Terms of Service and link to that node in this field.

Weight: Set as you wish

Visibility: Private field, content only available to privileged users.

Page title: Leave Blank

Now all you have to do is check mark the checkboxes at the bottom of page titled:
The user must enter a value & Visible in user registration form.

-----Submit Form-----

Now visit the new registration form to see what's been created! : )






Using Drupal 4.7:
______________________________

Go to (administer > settings > profiles)
Add a "checkbox" field, by clicking on the checkbox link under Add new field.

Now you are presented with a form, for the new profile field.
Fill out the form as follows (wording can be changed to suit your own use case)

Category: Terms Of Service (This will be the category under which the terms of service will be shown on the registration page)

Title: I Agree (Title of the checkbox itself)

Form Name: profile_tos (The field the checkbox will occupy in the database)

Explanation:
Here you can list your Terms of Service that should be read over, before checkmarking the checkbox. or you could create a node for the Terms of Service and link to that node in this field.

Weight: Set as you wish

Visibility: Private field, content only available to privileged users.

Page title: Leave Blank

Now all you have to do is check mark the checkboxes at the bottom of page titled:
The user must enter a value & Visible in user registration form.

-----Submit Form-----

Now visit the new registration form to see what's been created! : )






Special Thanks: to Drupal User Florian for bringing this method to the attention of Community Members by way of the forums.

Thanks: to Drupal User Chill35 for proofreading and double checking steps involved to insure that steps are correct.

Comments

Another approach in new

Another approach in new module:

<?php
function example_form_alter(&$form, $form_state, $form_id) {
  if(
$form_id == 'user_register') {
 
$form['legal'] = array(
     
'#type' => 'fieldset',
     
'#title' => t('legal'),     
    );
 
$form['legal']['select'] = array(
     
'#type' => 'checkbox',
     
'#title' => t('agreement'),
     
'#default_value' => 1,
     
//'#validate' => array('example_form_n11_validate1236'), //Why doesn't it work here?
     
'#description' => t('You must agreement the '.l('terms','node/6').', otherwies you should exit'),     
    );   
 
$form['#validate'][] ='example_form_validate_custom'; //It works very well, but loading every validation?
 
}
}
function
example_form_validate_custom($form, &$form_state) {
   
$legal = $form_state['values']['select'];  
    if (
$legal===0) {
       
form_set_error('select', 'Please check the agreement.');
    }
}
?>

Any comments and suggestion are always welcome!

Would you like to answer my questions in the code?
//'#validate' => array('example_form_n11_validate1236'), //Why doesn't it work here?
$form['#validate'][] ='example_form_validate_custom'; //It works very well, but loading every validation?

Page status

About this page

Drupal version
Drupal 4.7.x, Drupal 5.x, Drupal 6.x

Site Building Guide

Drupal’s online documentation is © 2000-2013 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