Add "I agree with tos" checkbox to user registration form

Public

Add to your module or theme's template.php

Get raw version
php
  1. /**
  2.  * Implements hook_form_FORM_ID_alter().
  3.  */
  4. function modulename_form_user_register_form_alter(&$form, &$form_state, $form_id) {
  5. // Modification for the form with the given form ID goes here. For example, if
  6. // FORM_ID is "user_register_form" this code would run only on the user
  7. // registration form.
  8.  
  9. // Add a checkbox to registration form about agreeing to terms of use.
  10. $form['terms_of_use'] = array(
  11. '#type' => 'checkbox',
  12. '#title' => t("I agree with the website's !tos", array('!tos' => l(t('terms and conditions'), 'node/put_node_id_here'))),
  13. '#required' => TRUE,
  14. '#weight' => 100,
  15. '#prefix' => '<p>',
  16. '#suffix' => '</p>',
  17. );
  18.  
  19. }

Comments

Anonymous's picture

This would be a lot more helpful with validation and submission functions. With that said, I would just use https://drupal.org/project/legal .