2

For Drupal 6.x is there a module that makes it a requirement that the user check a check box before logging in?

The site needs to require every user to accept the Terms and Conditions at each login, not just at registration.

3 Answers 3

3

There are two modules, http://drupal.org/project/legal and http://drupal.org/project/terms_of_use, that require you to accept on registration (I guess you found those already).

What you need (accept on every login) is not a feature of those modules, as far as I know. However I think that is should not be too hard to write a custom module, re-using some of the code of one of those modules, that adds this checkbox to every login form.

If you have not written modules before, check out the module developer's guide on drupal.org. You will have to use hook_form_alter to add a checkbox to the login form.

0

@marcvangend thank you for the info and links, here is the code I found/edited/came up with:

function toscheckbox_form_user_login_alter(&$form, &$form_state) {
  // Add a checkbox to login form about agreeing to terms of service.
  $form['terms_of_service'] = array(
    '#type' => 'checkbox', 
    '#title' => "I agree with the website's terms of service.", 
    '#required' => TRUE
  );
}

function toscheckbox_form_user_login_block_alter(&$form, &$form_state) {
  // Add a checkbox to login form about agreeing to terms of service.
  $form['terms_of_service'] = array(
    '#type' => 'checkbox', 
    '#title' => "I agree with the website's terms of service.", 
    '#required' => TRUE
  );
}
2
  • Does that really work as expected? Correct me it I'm wrong, but I think that '#required' => TRUE will only check if a valid value has been entered. For a checkbox, both 1 and 0 are valid values, so an unchecked box would still pass the #required test. Nov 20, 2010 at 16:11
  • @marcvangend yes this worked for me. I tried checking and unchecking it, and I could not find a way to login without checking that box.
    – Joe Mako
    Dec 1, 2010 at 19:02
0

Even easier, when they log in, redirect them to a page that contains a little javascript.

Like so:

1) Create this trigger/action set: [Trigger] User Logs In -> [Action] Redirect to /mustagree

2) Add content page mustagree:

if ( confirm('Terms: \n You must be older than 18 to enter. \n \n Do you agree to these terms?') ) { window.location = 'userhomepage' } else { window.location = 'logout' }

Assuming you have a content page with the url userhomepage this will work perfectly.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.