Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

Looking for a plugin to ensure that casual (NOT logged in) users of my site will agree to the Terms of use. That is, first time they try to access ANY page on site, display terms and prompt for agreement. If suer agrees, store that in DB (preferable) or cookie.

I cam across "Terms of Use" plugin, but it has not been updated in over a year and I am not sure it supports my scenario.

TIA for any help.

Jackie

share|improve this question
1  
Keep in mind that this can conflict search engines. Robots are driven by companies (which are nothing else as legal entities and therefore users) but they cannot accept your terms automatically. –  hakre Feb 11 '11 at 0:14
    
Good point. Worth adding that displaying content solely for Google is likely considered "cloaking" and is probably a bad idea. –  editor Feb 11 '11 at 0:19

2 Answers 2

I wrote something like that in the past that check for a cookie before loading the page and if the cookie wasn't found the page would display something like the terms of services and a checkbox to agree, so only after the guest agrees he can see the content.

i'll see if i can find that code.

UPDATE

O.k found most of it so we create a function that checks if the user is logged in and if not we check to see if he has our cookie if not we display our T.O.S instead of the content so we hook that to the_content hook

function to add_filter('the_content','check_tos_656');

function  check_tos_656($content){
    //only for none logged in guests
    if (!is_user_logged_in()){
        //check if guest has agree cokkie
        if(!check_cookie_tos()){
            $content = show_tos();
        }
    }
    return $content;
}

no you can see two function in there

  • check_cookie_tos() a function to see if the cookie exists.
  • show_tos() a function to display our T.O.S and an agree checkbox and button.

so here they are:

function check_cookie_tos(){
    if (isset($_COOKIE['agreed_TOS'])){
        if ($_COOKIE['agreed_TOS'] =="I_aggre"){
            return true
        }
    }
    return false;
}

function show_tos(){
    $out = '<h3>You Must Agree to our T.O.S blablabla</h3>
    //here you can put your TOS
    blablabla
    blablabla
    blablabla';

    $out .= '<form name="tos_check" method="POST" action="">
        <p>
            <input type="checkbox" name="tos_agree" id="tos_agree" value="yes" /> I Agree!<br />
            <input type="submit" name="submit_tos" id="submit_tos" value="submit">
        </p></form';
    return $out;
}

now you can see that we have a form that will submit the guest's agreement to the T.O.S so we need to process that and create the cookie so here it is:

if (isset($_POST['check_cookie_tos']) && $_POST['check_cookie_tos'] == "yes"){
    setcookie("agreed_TOS", "I_aggre", time()+3600, "/", str_replace('http://www','',get_bloginfo('url')) );
}

you would have to set your own T.O.S in the code but if enough people will ask i'll turn this into a plugin and add a simple admin panel.

Enjoy.

share|improve this answer
    
Nice work here! –  editor Feb 11 '11 at 0:18
    
@Editor - thanks its something i cooked a long time ago but now i coded most of it from scratch. –  Bainternet Feb 11 '11 at 0:55

I've done a more general survey of ToS plugins in the past, but found them lacking features beyond putting an extra form field on a login form. For example, I wanted the user to actually scroll through the ToS before blindly agreeing, but that didn't exist so I had to write it.

That said, the login forms don't have as many action and template hooks as other parts of the core, so it could be in part a side-affect of that.

Requiring agreement before any content is shown is so very specific that I am pretty confident you're going to be out of luck. Totally doable though.

share|improve this answer
    
i think he is asking more about guest and not registered or registering users. –  Bainternet Feb 10 '11 at 20:44
    
Question says "first time they try to access ANY page on site, display terms and prompt for agreement." Seems to me you would have to wrap your loop in some cookie-checking code. –  editor Feb 10 '11 at 21:01
1  
If you edited something, you hopefully LiteSpeed –  hakre Feb 11 '11 at 0:27
    
I do make a habit out of editing my comments :) –  editor Feb 11 '11 at 0:31

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.