A JavaScript-based age verification system for WordPress websites that manages content visibility based on user age and preferences.
- Age-based content filtering: Restricts access to specific content blocks based on user age
- Cookie-based persistence: Remembers user preferences across sessions
- Modal interface: Clean, overlay-based age verification form
- Content toggling: Dynamically shows/hides casino highlight blocks based on verification status
- Checkbox preference: Allows users over 24 to opt-in/out of seeing advertisements
- Under 18: Users cannot see casino/advertisement content
- 18-23: Users cannot see casino/advertisement content
- Over 24: Users can choose whether to see casino/advertisement content via checkbox
- Sets
canSeeAdscookie with appropriate value based on age selection - Cookie expires after 1 day for under-24 users, 365 days for over-24 users
- Automatically checks existing cookie on page load to maintain user preferences
The script targets elements with the .code-block class to show/hide casino-related content:
- Adds
d-noneclass to hide content - Removes
d-noneclass to show content
- Shows modal overlay on first visit (no existing cookie)
- Hides modal after age verification
- Prevents body scrolling while modal is active via
overflow-hiddenclass
The script expects specific HTML elements to be present. A complete modal template is provided in footer.php which includes:
- Modal container (
.modal-verificationwith#modal_verificationID) - Overlay background (
.modal-overlayer) - Age selection buttons (
#under-18,#18-23,#over-24) - Advertisement preference checkbox (
#age_verify) - Content blocks with
.code-blockclass for controlled visibility
Advanced Custom Fields (ACF) Integration: The modal template uses ACF fields for dynamic content management:
avs_header_logo- Modal header logoavs_heading- Main heading textavs_subheading- Subheading textavs_description- Description textavs_button_1,avs_button_2,avs_button_3- Age selection button labelsavs_verification_check_text- Checkbox label textavs_confirmation_text- Bottom confirmation text
To use the provided template:
- Install and configure Advanced Custom Fields (ACF) plugin
- Set up the required ACF option fields
- Include
footer.phpin your WordPress theme - Or copy the modal HTML structure to your existing template files
.modal-visible: Shows the verification modal.visible: Shows the overlay background.overflow-hidden: Prevents body scrolling.d-none: Hides content blocks.code-block: Target elements for content control
- Install and configure the Advanced Custom Fields (ACF) WordPress plugin
- Set up the required ACF option fields (see ACF Integration section above)
- Include jQuery (script dependency)
- Add the
age-verification.jsscript to your WordPress theme - Include the
modal.cssstylesheet in your theme (or copy styles to your main stylesheet) - Include the
footer.phptemplate in your WordPress theme or copy its HTML structure to your existing templates - Ensure content blocks use the
.code-blockclass for age-based visibility control
To enqueue the CSS file in WordPress:
Add this to your theme's functions.php:
wp_enqueue_style('age-verification-modal', get_template_directory_uri() . '/age-verification/modal.css');age-verification.js- Main JavaScript functionalityfooter.php- Complete HTML template with modal structuremodal.css- Professional styling for the modal componentsREADME.md- Documentation
- jQuery library
- Advanced Custom Fields (ACF) WordPress plugin
- CSS classes for modal visibility and content hiding