Age verification in javascript

Saved searches

Use saved searches to filter your results more quickly

You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session.

A simple age verification modal for websites that need to confirm if you’re over a specific age. Designed for Breweries and bars

alexstandiford/easy-age-verifier

This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?

Sign In Required

Please sign in to use Codespaces.

Launching GitHub Desktop

If nothing happens, download GitHub Desktop and try again.

Launching GitHub Desktop

If nothing happens, download GitHub Desktop and try again.

Launching Xcode

If nothing happens, download Xcode and try again.

Launching Visual Studio Code

Your codespace will open once ready.

There was a problem preparing your codespace, please try again.

Latest commit

Git stats

Files

Failed to load latest commit information.

README.MD

Easy Age Verifier makes it easy for taprooms and bars to confirm their website visitors are of legal age. The plugin was designed to work out of the box, but can be easily customized in the settings page, as well as a series of hooks and filters.

  • Ask users to verify their age on page load. If the user is less than the age you specify (default is 21), then they will be removed from the website
  • Customize all items on the form, including the question asked, the message stated when they’re underage, and the class each form item has.
  • Remembers if a visitor has verified their age in the past, and won’t ask again until they close their web browser.
  1. Upload the plugin files to the /wp-content/plugins/plugin-name directory, or install the plugin through the WordPress plugins screen directly.
  2. Activate the plugin through the ‘Plugins’ screen in WordPress
  3. (Optional) Configure the form, including minimum age, and all messaging for the form on settings>>>Easy Age Verifier

Easy Age Verifier comes with 2 different ways to verify your visitor is of age. The form that you wish to use can be customized on the Easy Age Verifier settings page.

  1. Enter Age Form (default)
  • This form requires that the visitor enters their date of birth
  1. Confirm Age Form
  • This form does not require that the visitor enter their date of birth. Instead, they simply click on one of two buttons, that says they’re either of age, or they’re not of age.
Читайте также:  Image center crop python

Easy Age Verifier has a few filters that allow theme developers to customize defaults for this plugin. Most of these can be overridden by the administrator under settings>>>Easy Age Verifier

  • eav_custom_modal_logic
    • Allows developers to create custom functions to override when Easy Age Verifier attempts to verify a visitor’s age
    • Default: Array(‘default’,true);
      • More information on how to use this here.
      • Sets the default age to check against
      • Default: 21
      • Sets the default message to display if the website visitor is underage.
      • Default: Sorry! You must be $age to visit this website.
      • Sets the default content to display above the form.
      • Default: Verify Your Age to Continue
      • Sets the default content to display inside of the button that says the visitor is underage.
        • This filter only applies to the confirm age form, not the enter age form.
        • Sets the default content to display inside of the button that says the visitor is of age.
          • This filter only applies to the confirm age form, not the enter age form.
          • Sets the default wrapper class.
            • IMPORTANT: If you override this class and do not update the CSS to display properly, this will prevent your form from displaying properly. This is intended for advanced users only.
            • Sets the default form class.
            • Default: taseav-form-class
            • Adds html before the form
            • Default: null
            • Adds html after the form
            • Default: null
            • Replaces the default month class
            • Default: taseav-month
            • Replaces the default day class
            • Default: taseav-day
            • Replaces the default year class
            • Default: taseav-year
            • Replaces the default minimum year value
            • Default: 1900
            • Adds html before the year div
            • Default: null
            • Adds html before the day div
            • Default: null
            • Adds html before the month div
            • Default: null
            • Adds html before the submit button
            • Default: null
            • Replaces the default button text
            • Default: Submit
            • Replaces the body class that’s loaded in by Easy Age Verifier
            • Default: taseav-verify-success on success, taseav-verify-failed on failed
            • eav_verification_failed
              • An action before the javascript fires allowing redirects or other usages

              Easy Age Verifier also has built-in support for overriding how the Javascript behaves when the verification passes or fails on-submit. This allows you to override the default behavior when verification fails/passes.

              To do this, you need to enqueue the Javascript file that contains the overriding actions. Be sure to set verify-age.js as a dependency, as this ensures that your overrides will work as expected.

              Enqueue the script with a WordPress action:

               /** * Enqueues the script that overrides the Javascript behavior of Easy Age Verifier */ function modify_eav_verifier_failed_action()< $url_to_js_file = get_stylesheet_directory_uri().'/eav-override.js'; //Change this to your own path wp_enqueue_script('verifier-override',$url_to_js_file,['verify-age.js']); //Set verify-age.js as a dependency > add_action('wp_enqueue_scripts','modify_eav_verifier_failed_action'); ?>
              verifier.doFailedAction = function() //Add actions to override what happens when the submitted form fails here >; verifier.doPassedAction = function() //Add actions to override what happens when the submitted form passes here >;

              To override the default verifier template, follow these steps:

              1. Locate the default template file located at /assets/templates/default.php
              2. In the root of your current theme directory, create a folder called eav .
              3. Copy default.php into your newly created eav directory
              4. Edit the file as you see fit.

              The eav_custom_modal_logic filter can be used to specify custom conditions that prevents the modal from popping up. The filter also allows you to specify a custom action when that specific conditional returns false.

              The filter is an associative array, which contains conditional IDs as the keys, and booleans (true, or false) as the values. if any of the values in this array return false , the modal will not pop-up, and an action will trigger for each boolean that returns false.

              By default, the array looks like this:

              Important! Do not modify the default item in this array. Removing it can cause unexpected behavior!

              Adding Custom Conditionals

              To add custom logic to your site, you need to add a conditional ID and a boolean to this array. Let’s say, for example, you wanted to only display your age verifier on the home page. You would add something like this to your functions.php file (or plugin file, if you’re fancy like that).

              //The function that adds the check. Be sure to pass the $checks variable function home_page_disable_verifier($checks)< //Check if the current page is the home page if(is_home())< //If it is, add the check ID key, and set it to true. $checks["is_home_page"] = true; // is_home_page can be whatever you want it to be. Make sure it's unique! > else< //If not, add the check ID key, and set it to false. $checks["is_home_page"] = false; > //Returns the array with the newly added boolean return $checks; > add_filter('eav_custom_modal_logic','home_page_disable_verifier');

              Doing Actions Based on Those Conditionals

              When a custom conditional returns false , an action hook tied to that conditional runs. This allows you to do a specified action, based on which conditional returns false.

              The action to tie your function is equal to whatever your check ID is inside of the array, with _custom_is_false added to the end. In the case of the example above, that action would be is_home_page_custom_is_false .

              Let’s say you wanted to display a warning instead of the age verifier when the home page is loaded. To do this, you would add the filter shown above, and then after that add something like this:

              //The function that adds the content if you're on the home page. function load_home_page_warning()< echo "Warning! Content on this site is not suitable for visitors under the age of 18."; > //Ties the action to when the home page returns false. add_action('is_home_page_custom_is_false','load_home_page_warning');

              When a custom conditional returns true , an action hook tied to that conditional runs. This allows you to do a specified action, based on which conditional returns false.

              The action to tie your function is equal to whatever your check ID is inside of the array, with _custom_is_tue added to the end. In the case of the example above, that action would be is_home_page_custom_is_true .

              Let’s say you wanted to display a warning instead of the age verifier when the home page is loaded. To do this, you would add the filter shown above, and then after that add something like this:

              //The function that adds the content if you're on the home page. function load_home_page_warning()< echo "Welcome. Glad to see you're above the age of 18."; > //Ties the action to when the home page returns false. add_action('is_home_page_custom_is_false','load_home_page_warning');

              Sometimes, the verifier will display incorrectly on your site. To temporarily disable the form, but still provide you with a way to display the form, Easy Age Verifier comes with a built-in debug mode.

              To turn on Debug mode, visit the WordPress dashboard>>Age Verifier>>Debug Verifier, and click «Enable Debug Mode».

              When Debug Mode is activated, the verifier script will not run until you run verifier.getForm() command from the console.

              About

              A simple age verification modal for websites that need to confirm if you’re over a specific age. Designed for Breweries and bars

              Источник

              Saved searches

              Use saved searches to filter your results more quickly

              You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session.

              Simple Age Verification Script written in Javascript

              License

              juliankoehn/jquery.ageverification

              This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

              Name already in use

              A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?

              Sign In Required

              Please sign in to use Codespaces.

              Launching GitHub Desktop

              If nothing happens, download GitHub Desktop and try again.

              Launching GitHub Desktop

              If nothing happens, download GitHub Desktop and try again.

              Launching Xcode

              If nothing happens, download Xcode and try again.

              Launching Visual Studio Code

              Your codespace will open once ready.

              There was a problem preparing your codespace, please try again.

              Latest commit

              Git stats

              Files

              Failed to load latest commit information.

              README.md

              Simple Age Verification Script written in Javascript example http://juliankoehn.github.io/jquery.ageverification/example/

              Add this line somewhere after jQuery

              minAge: '', // default 18 cookie: < enabled: false, // default false days: '1', // default 1 >, redirectTo: '', // URI to redirect after Verification, default: none redirectToDeclined: '', // URI to redirect if failed, default: http://www.google.com months: [ , , , , , , , , , , , , ], errors: < invalidDay: 'Day is invalid or empty', invalidYear: 'Year is invalid or empty', tooYoung: 'You are not old enough', >, theme: 'default', // Theme Name (must match Folder name), default: default themePath: 'ageCheck/themes/', // Path to Theme Folder. Default: 'ageCheck/themes/ templateVars: < title: '', // in default theme Modal Title text: '', // in default theme modal text btnCancel: 'Cancel', btnSubmit: 'Proceed', >

              To add templateVars just extend the «templateVars» and wrap them into the template like .

              About

              Simple Age Verification Script written in Javascript

              Источник

Оцените статью