'Add Terms of Use to the registeration form.', 'title' => 'Terms of Use', 'page callback' => 'drupal_get_form', 'page arguments' => array('terms_of_use_admin_settings'), 'access arguments' => array('administer site configuration'), ); return $items; } function terms_of_use_admin_settings() { $form['terms_of_use_node'] = array( '#type' => 'textfield', '#title' => t('Node id where Terms of Use are published'), '#default_value' => variable_get('terms_of_use_node', ''), '#description' => t('Node id of the page or story where Terms of Use are published. Do not promote this node.'), ); $form['terms_of_use_title'] = array( '#type' => 'textfield', '#title' => t('Title of the Terms of Use fieldset.'), '#default_value' => variable_get('terms_of_use_title', t('Terms of Use')), '#description' => t('The Terms of Use and the checkbox appear in a fieldset. Type here a title for that fieldset.'), ); $form['terms_of_use_text_next_to_the_checkbox'] = array( '#type' => 'textfield', '#title' => t('Text that will appear next to the checkbox.'), '#default_value' => variable_get('terms_of_use_text_next_to_the_checkbox', t('I agree with these terms.')), '#description' => t('Type here something like "I agree with these terms." or "I CERTIFY THAT I AM OVER THE AGE OF 18 YEARS OLD." Without quotes.'), ); return system_settings_form($form); } /* * Implementation of hook_form_alter */ function terms_of_use_form_alter(&$form, $form_state, $form_id) { if ($form_id == 'user_register') { // Adding the fieldset $form['terms_of_use'] = array( '#type' => 'fieldset', '#title' => variable_get('terms_of_use_title', t('Terms of Use')), '#weight' => 10, ); // Getting the node that contains the Terms of Use $node = node_load(variable_get('terms_of_use_node', '')); if (isset($node)) { $terms_of_use = node_prepare($node)->body; } else { $terms_of_use = ''; } // Adding the Terms of Use to the fieldset $form['terms_of_use']['terms_of_use_text'] = array( '#prefix' => '
', '#value' => $terms_of_use, '#suffix' => '
', ); // Adding the Terms of Use to the fieldset $form['terms_of_use']['I_agree'] = array( '#type' => 'checkbox', '#title' => variable_get('terms_of_use_text_next_to_the_checkbox', t('I agree with these terms.')) . ' *', '#required' => TRUE, '#element_validate' => array('_terms_of_use_validate_checkbox'), ); } return $form; } function _terms_of_use_validate_checkbox($form, &$form_state) { $value = $form_state['values']['I_agree']; // drupal_set_message('
 ' . print_r($form_state['values'], TRUE) . '
'); if ($value == 0) { form_set_error('I_agree', t('You must agree with the Terms of Use to get an account.')); } }