How to Add Age Verification in WordPress
In this article
Adding age verification to your WordPress site restricts access to age-sensitive content, such as alcohol, tobacco, or adult material. This guide shows you how to implement a simple age gate using a plugin, configure it correctly, and avoid common pitfalls. You'll need a WordPress admin account and the ability to install plugins.
What You'll Need
- A WordPress site with admin access.
- A plugin for age verification (free options like Age Gate or WP Age Verify are fine).
- Basic knowledge of WordPress settings and menus.
Step-by-Step
- Install a plugin. In your WordPress dashboard, go to Plugins > Add New. Search for "age verification" or "age gate". Choose a plugin with good ratings and active installs. Click Install Now, then Activate.
- Open the plugin's settings. After activation, you'll usually find a new menu item like Age Gate or Settings > Age Verify in the sidebar. Click it to open the configuration page.
- Set your minimum age. Look for a field labeled Minimum Age or Age Limit. Enter the required age, e.g.,
18or21. This is the age users must confirm they are. - Choose the verification method. Most plugins offer two options: a simple checkbox ("I am 18 or older") or a date-of-birth entry. For legal compliance, a date of birth is more robust. Select the method that suits your needs.
- Customize the message and button text. Edit the text that appears on the overlay, such as "You must be 18+ to enter this site." Change the button labels (e.g., "Enter" and "Leave") to match your site's tone.
- Set cookie duration. Decide how long the verification should be remembered. A common setting is 30 days or 1 year. Shorter durations are more secure but may annoy users. Save your changes.
- Apply the gate to specific pages. If you only want age verification on certain pages (e.g., product pages), look for a setting like Apply to or Page Restrictions. Choose "Whole Site" for global coverage, or select specific pages or post types.
- Test the age gate. Visit your site in a private/incognito window. You should see the age verification overlay. Click "Enter" to confirm it works. Then clear cookies and test the "Leave" button to ensure it redirects to a safe page (like your homepage or a goodbye page).
- Adjust redirect for underage users. Set the URL for users who fail verification. This could be a page explaining why they can't enter, a search engine, or your site's homepage. Save the URL in the plugin's settings.
Common Mistakes
- Not testing in incognito mode. If you're logged in as admin, the plugin may skip the gate, so you might think it's broken or working when it isn't.
- Setting the cookie too long. A year-long cookie might be acceptable, but if you need stricter compliance, shorter is better. Check your local laws.
- Forgetting to update the redirect URL. If the "Leave" button leads to a 404, users get stuck. Always set a valid URL.
- Applying the gate to admin pages. Some plugins can accidentally block your login or admin area. Make sure the plugin is configured to exclude logged-in users or admin pages.
- Using a plugin that conflicts with your theme. Rarely, a theme's CSS can hide the overlay. If the gate doesn't appear, check for CSS conflicts.
Tips
- Use a date-of-birth field for legal compliance. A simple checkbox is easier to bypass and may not meet regulatory requirements in some jurisdictions.
- Keep the design consistent. Most plugins allow you to change colors and fonts. Match the overlay to your site's branding for a professional look.
- Consider mobile users. Ensure the overlay is responsive and doesn't cause layout issues on small screens.
- Back up your site before installing. Use a backup plugin or your host's backup service. This way, if anything breaks, you can restore quickly.
- Check plugin updates regularly. Age verification plugins need to stay current with WordPress core and security patches.
Troubleshooting
The age gate doesn't appear. First, clear your browser cookies and test again in incognito. If it still doesn't show, check that the plugin is active and the settings are saved. Also, verify that your theme isn't suppressing the overlay due to CSS. Try switching to a default theme temporarily to see if it's a conflict.
The gate appears on the login page. This is usually because the plugin is set to apply to the whole site. Look for an option to exclude admin or login pages. If not, you may need to add a code snippet to exclude them.
Users can bypass the gate by disabling JavaScript. Some plugins rely on JavaScript. For stronger protection, choose a plugin that also works with PHP (server-side). If your plugin is JS-only, consider an alternative.
The "Leave" button doesn't redirect. Double-check the redirect URL in settings. Make sure it's a full URL (e.g., https://example.com/exit). Also, ensure the page exists and is not set to noindex.
After updating WordPress, the gate breaks. Plugin compatibility issues can occur. Update the plugin to the latest version, or contact the plugin support. If the plugin is no longer maintained, switch to a different one.
Frequently Asked Questions
Is age verification required for all websites? No, it's only required if you have age-restricted content (alcohol, tobacco, adult material, gambling). For general sites, it's optional.
Can I add age verification without a plugin? Yes, you can add custom code to your theme's functions.php file. However, using a plugin is easier and safer for non-developers.
Will age verification affect my SEO? Generally, no. The overlay is client-side and doesn't hide content from search engines. However, if you use a redirect for underage users, make sure it's a 302 temporary redirect, not a 301, to avoid SEO issues.
Can I set different age limits for different pages? Yes, some plugins allow per-page or per-category settings. Check your plugin's documentation for this feature.
What if a user enters a fake birth date? Age verification based on self-reported data cannot be 100% foolproof. For higher security, you might need third-party ID verification, but that's more complex and costly.
How do I remove the age verification later? Simply deactivate and delete the plugin. If you've added custom code, remove it from your theme files.