Take the 2-minute tour ×
Webmasters Stack Exchange is a question and answer site for pro webmasters. It's 100% free, no registration required.

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.

share|improve this question

3 Answers 3

up vote 3 down vote accepted

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.

share|improve this answer

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.

share|improve this answer
    
Thanks, I'll try that out. –  Joe Mako Mar 9 '11 at 4:03

@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
  );
}
share|improve this answer
    
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. –  marcvangend Nov 20 '10 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 '10 at 19:02

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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