Jump to content

How can I add an age verification popup?

Recommended Posts

I’m creating a website for a local brewery and need to figure out how to add an age verification request that pops up when visitors come to the site for the first time. Just needs to be basic and ask “Are you 21?” If “Yes,” let them into the site, if “No,” send somewhere else.

I searched and found a bunch of JavaScript options, but I can’t figure out how to implement it, since Squarespace 6 file modification & storage is limited.

Thanks in advance!

Link to comment
  • Replies 11
  • Created
  • Last Reply

Perhaps you might want to check out IDology's, ExpectID Age product that will help keep compliance while quickly confirming someones age accurately.

On the other hand the code below will do the most basic aspect if put on the main landing pages.


<?php
session_start();
if ($_REQUEST["over21"] == 1) {
   $_SESSION["over21"] = 1;

   header("Location: " . $_REQUEST["redirect"]);
}
?>
<html>
   <head>
       <title>Verify Your Age</title>
   </head>
   <body>
       <a href="verify.php?over18=1&
redirect=<?=$redirect?>">I am over 21</a> | 
       <a href="http://www.google.com/">I am not over 21</a>
   </body>
</html>

Link to comment
  • 2 weeks later...
  • 2 months later...
  • 7 months later...

I just faced this problem myself (although I needed a verification page, not a pop-up). I couldn't find a solution that satisfied my requirements. I now this post is more than 6 months old, buy I'm leaving my answer in case anyone else needs it.

You can get my code at https://github.com/cotupha/octli

It has the javascript necessary, as well as other files that serve as example demonstraiting how to use the javascript. It is explained how to do it without activating developer mode (which was a requirement of my client).

Link to comment
  • 5 months later...
  • 6 months later...

@cotupha thank for sharing, I'm having difficulties implementing your code on squarespace platform, is it possible for you to explain the steps in to implement. Any help greatly appreciated!

Link to comment
  • 2 months later...
  • 2 months later...

@cotupha (or anyone else) Would you be able to help me get this set up? I'm a bit confused on a couple of the steps. I'd be willing to pay you for your time.

Link to comment
  • 2 months later...

"... It is explained how to do it without activating developer mode (which was a requirement of my client)..."

For those confused, it took me a minute of confusion as well, but according to Cotupha's instructions you would still have to set up the age verification code outside of squarespace. The first two steps wouldn't be possible with squarespace hosting as-is (non developer mode).

As it stands – I don't see any solution on the boards for an age verification that isn't just a cover page.

Link to comment
  • 1 year later...
  • 1 year later...

I built a simple age-gate solution for Squarespace. It's available here:

https://sf.digital/squarespace-age-popup

There's a small one-off charge to use it on your site. If you need a more advanced or customised solution, we can build these too.

-Paul

Squarespace Expert & Professional Developer

Improve your online store with our extensions.
About: Squarespace Circle Leader since 2017. I value honesty, transparency, appreciation and great design ♥.
Work: Squarespace Developer and founder of SF Digital, building the features Squarespace didn't include™.
Content: Links in my posts may refer to SF Digital products or may be affiliate links.

Buy me a coffee

Link to comment

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Squarespace Webinars

Free online sessions where you’ll learn the basics and refine your Squarespace skills.

Hire a Designer

Stand out online with the help of an experienced designer or developer.