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 came across "Terms of Use" plugin, but it has not been updated in over a year and I am not sure it supports my scenario.


  • 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

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.


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
            $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

    $out .= '<form name="tos_check" method="POST" action="">
            <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">
    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.


  • 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.

  • 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

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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