Hello all,
I've gone through the Forums looking for a way to implement a Terms & Conditions setting...and have not found one yet. The 'Legal' module has not been updated since 4.3, although it's author said last month he will look for a way to make it work with the 4.5 series. I've also fiddled with the profile module...creating a checkbox and putting 'Terms & Conditions' next to it. It works correctly for one user, however, when two or more users also agree, my 'Terms & Conditions' becomes a link in everyones profile account, much like country or gender here on Drupal. That's silly for Terms & Conditions. Anyone have an idea how to implement this?

Thanks,
Larry

Comments

mikeryan’s picture

...just this past week, for my Fenway Views site. I've provided my changes to the legal module owner (Robert Castelo) and he passed them on to Killes, who was also working on upgrading the module. I also changed the terms display from a textarea to a div (scrollable, with a touch of CSS) so it can be formatted with HTML. Attachments seem to be disabled for comments, but here's the important function:

function legal_user($type, &$edit, &$user, $category) {
    // What type of registration action are we taking?
    switch ($type) {
      case t("register"):
      	$terms = variable_get("legal_terms", "edit T&C");
      	if ($terms == 'edit T&C') {
          return array();
        }
        // Add items to the registration form.
        $output .= "<div class='legal-terms'>$terms</div>\n";
        $output .= form_checkbox("<strong>Accept</strong> Terms & Conditions of Use",
                                 legal_accept, 1, $edit["legal_accept"]) . "\n";
        $output .= form_hidden('legal_register', '1') . "\n";
        return array(
                array('title' => t('Terms and Conditions of Use'), 
                      'data' => $output, 
                      'weight' => 0));
      case t("validate"):
        // The user has filled out the form and checked the "accept" box.
        if (($edit["legal_register"] == '1') && ($edit["legal_accept"] != "1")) {
          form_set_error('legal_accept', t("You must <strong>accept</strong> the Terms & Conditions of Use to register."));
        }
        break;
    }
  }
 

And the legal.css file I added:

.legal-terms {
  height: 20em;
  overflow: scroll;
}
czarphanguye’s picture

Thanks for the Legal code, it looks very nice on your site -- but; what does one do with the above php code? 8-|

mikeryan’s picture

In the file legal.module, replace the existing legal_user function with the PHP code I provided. Also, you need to add that snippet of CSS to the style.css file for your theme - otherwise the whole thing will appear without scrollbars, which may be fine if you have a short terms & conditions statement.

czarphanguye’s picture

Dear mike,

Thank you for your assistance. Your code did the trick for my registration page as well.

larry’s picture

Hello mikeryan,
Thank you very much for the code and module update, works like a charm. I have one question though, where is the information stored...or is there any to store? I mean, if user xyz clicks 'I accept', where is that exactly stored? In the profile module, which I only use for reference, you created your own database table. Is this information actually stored anywhere or is it just a barrier to entry that must be crossed? Thanks again for your work and sharing.

Ciao,
Larry

Oh...I gotta ask. Do you know how to make the description appear in 'admin/modules'? I know it does not really matter for functionality...I'm just curious because the hooks are driving me nuts and I'd like to learn how they work. Thanks again.

--There are no Kangaroos in Austria--

mikeryan’s picture

Right now, the legal module just presents a barrier which must be crossed at registration time, nothing is stored. However, I would like to see it enhanced so users would be forced, if the administrator chooses, to re-accept the terms & conditions when they're changed. I.e., the acceptance would be stored as a boolean, and a checkbox in the settings would indicate whether the administrator wants re-acceptance - if checked, that boolean would be cleared for all registered users, and at login time if the value is false the user would need to review and accept the new terms.

As for the module description, that's set in the help hook. This is the current legal_help() I have:

function legal_help($section = "admin/help#legal") {
  $output = "";

  switch ($section) {
    case 'admin/help#legal':
      $output .= "<p>Adds Terms & Conditions statement to registration page, requires visitor to accept T&C to register.</p>";
      $output .= "<p>When a user creates an account you can require them to accept your Terms & Conditions for use of the site.</p>";
      break;
    case 'admin/modules#description':
      $output = t("Adds Terms & Conditions statement to registration page.");
      break;
    case 'admin/system/modules/legal':
      $output = t("Adds Terms & Conditions statement to registration page. Require users to accept your T&C before they can create an account.");
      break;
    case 'admin/legal':
      $output = t("Adds Terms & Conditions statement to registration page.");
      break;
  }
  return t($output);
}
larry’s picture

Thanks for your reply. Your idea about re-acceptance of Terms & Conditions is an interesting one. It could be extended to all sorts of other things like site-wide announcements or a user rating system. I appreciate you sharing your module...works very nicely. Thanks again.

Ciao,
Larry

--There are no Kangaroos in Austria--

P.Smith’s picture

hi mikeryan,

Thank you for the patches.

Also, good idea; it would be great to be able to force users to re-accept the T&C.

-Ryan

robert castelo’s picture

Legal module collects all the necessary data to have a T&C versioning system as described above, it's a feature I was planning to implement, just never had the time to do it. I'll try to get it done after I update the module for 4.7.

Cortext Communications
Drupal Themes & Modules

------------------------------------------
Drupal Specialists: Consulting, Development & Training

Robert Castelo, CTO
Code Positive
London, United Kingdom
----

creatorsdream’s picture

Wondering if anything is being done to get the legal.module to work in 4.7. I've downloaded and added the fix referenced here but am not able to get to display the Terms and Conditions in the registration form at all. I'm using 4.7 beta6.

robert castelo’s picture

Legal module will be updated for 4.7 shortly before Drupal 4.7 is released.

Cortext Communications
Drupal Themes & Modules

------------------------------------------
Drupal Specialists: Consulting, Development & Training

Robert Castelo, CTO
Code Positive
London, United Kingdom
----

stretchwickster’s picture

Recently, I have been trying to implement a terms & conditions checkbox to use at the bottom of my registration page, not knowing that a module provided this facility already. I stumbled across this thread, found the legal module, installed it in no time at all and it was working perfectly right out of the box. Excellent work to all involved in the creation of this module. Many thanks.