Customizing the Form Locker Age Verification Message


Want to personalize the age verification message shown by the Form Locker addon if a user’s age doesn’t match your requirements? By default, when you configure the Form Locker settings to demand age verification, a standard message is displayed for users whose birthdate doesn’t meet the criteria. With a simple PHP snippet, you can tailor this message to suit your preferences. We’ll guide you through the process!

Creating the form

Let’s get started by crafting a new form and incorporating the necessary fields.

After adding your desired fields, navigate to the Settings tab and locate Form Locker. Activate verification by clicking the Enable verification button. From the Type dropdown, opt for Age.

Feel free to include a personalized message that will appear before your form, explaining to users the reason for requesting their birthdates.

create your form, add your fields and enable the age verification on the Form Locker tab

If you need any assistance with creating this type of form, please check out this documentation.

Adding the snippet

Now it’s time to add the snippet to your site. If you need help with how and where to add snippets, please check out this tutorial.

 * Customize the Form Locker Verification Error Message
 * @link
function wpf_dev_form_locker_restriction_message( $message, $form_id, $form_data ) {

	// Only run on my form with ID = 2189
    if ( absint( $form_data[ 'id' ] ) !== 2189 ) {
        return $message;
    // Change the verification error message
    $message = __('You are unable to apply as an individual volunteer because you do not meet the minimum age requirement. Please contact the site admin with other ways you can help support the cause.', 'text-domain');
    return $message;
add_filter( 'wpforms_form_locker_age_get_error_message', 'wpf_dev_form_locker_restriction_message', 10, 3 );

This snippet will only run on the form ID 2189, you will need to update this ID to match your own. For assistance in finding your form ID, please review this tutorial.

When a visitor doesn’t meet the age verification check now, they will see your customized message.

using this snippet you can now customize the age verification message

And that’s all you need to customize the message! Would you like to show the number of entries left on a form with the Form Locker addon’s entry limit? Check out our tutorial on How to Display Remaining Entry Limit Number.