Plugin for confirming 18+ years (age verification)

Hello.

I wish to find a plugin which covers the website with a message requiring a button confirmation for 18+ age on a website which is not for children to be visited. Basically if the person clicks YES a custom cookie is set to visit website. If NO is pressed then a redirect is done to a page like Google search engine.

This is mostly found on websites which are for adults, covering the whole website to not expose minors onto their content, but I can’t find such plugin for Grav. The idea is to set all these things (message, buttons, color of text and background, custom cookie) in the admin area (because different people have different likes).

The current plugins like Simple Cookie are not enough, because they don’t cover the whole website and can’t set a custom cookie.

If there is no such plugin designed, I wonder how much money something like this would cost from me to entice a designer’s team in making it, then have it available among Grav plugins so other may enjoy it too. I consider something like this highly important on any CMS, in order to protect minors online.

This is my first post. Sorry to bother with a request like this, but can’t find something like this online.

Colors could be customized via a custom CSS. And I don’t really see a purpose of a customized cookie :thinking: But overall doesn’t sound too complex.

1 Like

The purpose of a different cookie is to not interfere with some other cookie (used for example in consent with regards website using cookies). Such notifications towards visitors would need to be separate and not cancel one another.

Hello,

I’ve developed a work-in-progress Age Verification plugin for Grav CMS that might meet your requirements.

Age Verification Plugin – Work in Progress

It handles age verification server-side to ensure security and prevent bypassing by disabling JavaScript. The plugin allows customizable messages, button texts, and sets a separate cookie without interfering with other cookies.

Feel free to check it out and share your feedback!

2 Likes

Great work for starting point. Thank you.

I guess it would also need a “I am not under 18” button.

I would make en as a default language though, instead of pl

1 Like

I’ve made some minor updates to the Age Verification plugin. In the user/plugins/age-verification/templates directory, you’ll find the Twig/HTML template for the age verification page. You can freely edit and style it to add any desired content. As @Karmalakas mentioned, adding styling options to the admin panel doesn’t make much sense.

If you customize the template, please move it to user/themes/your-theme/templates. Similarly, move the configuration file :wink: age-verification.yaml to user/config. This will protect your changes from being overwritten by future plugin updates.

For multilingual support, you can add and edit phrases in the user/plugins/age-verification/languages.yaml file and use them in the template accordingly.

This is my first public plugin for Grav, so please keep in mind that my knowledge is quite limited.

1 Like

About buttons, what I believe @xxx meant, is to have two buttons:

  1. “I am 18”
  2. “I am not 18”

(of course texts should be more formal :slight_smile:)

Button 1 lets you proceed
Button 2 - redirects you to some customizable URL (I suppose one more field needed in the config)

And I would agree with this

2 Likes

Could you clarify whether the redirect URL for the “I am not 18” button should be an external address (which would be straightforward and could even be hardcoded in the template as a link), or an internal address within the site? If it’s internal, we might need to add functionality to exclude that address from the age verification cookie checks.

Good point about the internal address. but that maybe could be added to a plugins ToDo list as a future feature.

At this point I think it would be enough to make this just as a text field where user would enter a URI in admin (or string via YAML)

Done. Two buttons and in the configuration file there is an external address for redirection.

1 Like

Few more notes :slight_smile:

    BUTTON: 'I am 18 or Older'
    BUTTON_NO: 'I am not 18'

Suggestion:

    BUTTON: 'I am 18 or older' # lowercase "older"
    BUTTON_NO: 'I am under 18 years old'

Also age-verification.yaml and blueprints.yaml should be updated with all supported fields

Oh… And some default CSS would be nice too to make it prettier out of the box :slight_smile: Maybe simply some Quark theme classes could be used

1 Like

Thank you for the great work so far @q3d - I appreciate your time and effort. This will be useful to protect children online while providing an easy plugin for those adult services using Grav.

1 Like

I’ve added some fixes and default styles.

Question: Should the CSS file in assets also be moved to another folder to protect it from being overwritten by a new plugin version?

I’ll also work on adding configuration through the admin panel, though I have to admit that whenever I have to log into any admin panel (like WordPress or Joomla) to make changes, it makes my teeth hurt :wink:

1 Like

Yes. Everything customizable should be able to be moved in a new folder or something, in case people decide to custom that page according to their themes or something.

Sure, but… if I want to customize something, I:

  • disable the built-in styles,
  • modify the template to give it a structure that aligns with my project,
  • style it or use existing classes.

I’m not going to create an Elementor equivalent for Grav, and even if I could, I wouldn’t want to.

I also added path specification to the configuration: allowed and excluded paths, which should enable redirecting the user to an internal address as well.

It would probably be good to have the option to set age verification at the level of each page using its Custom Page Headers.


13.11.2024 18:33
I updated blueprints.yaml, and it appears that the plugin now also allows configuration directly from the admin panel.

1 Like

@q3d - I am too new on this forum, so I can’t send private messages (at least not yet). But I wish to send you a small donation of appreciation since your effort will likely help many adult websites in protecting children. Could you please contact me by private message with a PayPal link? (again, I cant start PMs, sorry about it)

Default CSS should be overwritten by updates. If users want to modify styling, they should do that on their own theme (or) via custom.css

1 Like