Tracking when user clicks "terms acceptance" link

Events happening in the community are now at Drupal community events on www.drupal.org.
Screenack's picture

I have a simple event I need to track.

User comes to a site's home page. To enter the site, the user must click a "terms acceptance" link on an enter page. If the user doesn't want to accept the terms, the site redirects the user back to the home page.

The flow is:

home page -> terms acceptance -> yes -> go to rest of site
home page -> terms acceptance -> no (or no action taken) -> back to home page
home page -> if user tries to access any other page, but terms not accepted -> redirect to terms acceptance page

Any recommendations on implementing this? I'd prefer to do this in D7 but I'm willing to do so in D6, too.

Thanks!

Comments

Ironic

Screenack's picture

It's funny how writing the question carefully reframes the idea. I found this module that may do the trick: http://drupal.org/project/terms_of_use

Kyle

Back to the drawing board

Screenack's picture

Sadly, Terms of Use won't cut it for my needs. I only need to "ToU" a few pages, not the entire site and this adds text for user registration.

I simply need to track whether, by clicking on a link, that the user has "agreed" to the terms on that page before allowing access to a few pages.

This would be something like:
User tries to access a section page (either by link or bookmark)
The target page would then process:
Session variable check whether variable "agreed" is set (or true)
If no, redirect to the agreement page (with link)
If set, allow user to view page

As always, thanks in advance!

Did you find the solution, Kyle?

jeepster's picture

I need to do exactly the same thing in my website, did you find the solution? Could you help me?

Thanks in advance!

What I did

Screenack's picture

I'm using webform PHP Filter core module and sessions.

Here is roughly the process:

  1. We'll use php to get and set session variables from the blocks where we want to swap visibility.
  2. Model the webform to gather the specific information you would like to capture.
  3. Enable that webform as a block.
  4. Create the block that is the content you wish to show after a user has entered data.
  5. Enable the "PHP Filter" module. Do not enable the php filter in any of the text input filters however, or do so at your own risk.
  6. Set the block visibility code as follows:
    for the webform/show first block:
    <?php
    $url
    = request_uri();
    if ( (! isset(
    $_SESSION['form_filed'])) && $url == "/thepage/youwant") {
       
    $_SESSION['form_filed']=1;
        return
    true;
    }
    ?>

    On the block you ultimately want to show:
    <?php
    $url
    = request_uri();
    if (isset(
    $_SESSION['form_filed']) && $url == "/thepage/youwant") {
        return
    true;
    }
    ?>
  7. Finally set up a redirect.php in your drupal root. All this php does is redirect back to the sending page. Yes, you can do this within webforms, but for whatever reason, the sessions variable do not register as they ought. This makes sure that the blocks "see" the set variable. For me this is a simple:
    <?php header("location:/thepage/youwant");?>
  8. There it is!

Notes: originally webform for D6 supported php filters on submissions, which is what I originally wanted BUT they took out as they see it as too high a security vulnerability. I suspect moving the php code into template.php would be better, or its own module.

So, I know; it's a lazy system. Merely refreshing the page will "let you in." But this is by design. It isn't meant to be Fort Knox, rather, if we get info, great. If not, we give out some marketing material anyhow.

By the way, I put this up there so the Drupal Illuminati can flay it seven ways to Sunday. I love learning better ways to doing things.

Thanks

jeepster's picture

Thank you, Kyle, you've been so kind to me. I'll try it tomorrow and I'll let you know.

Hi Kyle, I tried your method

jeepster's picture

Hi Kyle,

I tried your method but I did not get to anywhere..maybe my poor english misunderstood something.

Anyway, thanks! If I find another solution, I'll post it here.

What happened?

Screenack's picture

If you want to step through it, I'd be happy to help you through it. If it's not a good fit; that's cool, too.

What happened?

Screenack's picture

If you want to step through it, I'd be happy to help you through it. If it's not a good fit; that's cool, too.

What I did

jeepster's picture

Hi Kyle,

Thanks for your help.

I've finally used a popup to resolve the problem. You need to install Lightbox module.

In front page I put:

In the header:

$(document).ready(function () {
$('#lightboxAutoModal').triggerHandler("click");
$("#skip").click(function() {
Lightbox.end('forceClose');
});
});

In the body:

<?php
global $user;
?>

<?php
if (!isset($_COOKIE["welcomead"]) and !$user->uid) {
?>

LEGAL TEXT

<?php

//set a cookie "welcomead" 1 hour
setcookie("welcomead","Ad Viewed", time()+3600, '/','example.com');
}
?>

In the page.tpl: (cookie and user control):

<?php
global $user;
?>

<?php
if (!isset($_COOKIE["welcomead"]) and !$user->uid) {
drupal_goto('<front>');
}
?>

I hope this can help other people.

North Carolina

Group organizers

Group notifications

This group offers an RSS feed. Or subscribe to these personalized, sitewide feeds: