How to Add Accept Privacy Policy Checkbox for Sitewide Password Form

You have just built a password protected website so that only authorized users are allowed to see your private and high quality content.

Besides, it’s very important to you that the visitors read and accept the privacy policy of your website, especially to avoid any problems regarding collecting IP addresses without previous consent.

Wonder how to set up that simple checkbox for your site?

We know just the simplest way to achieve what you want. Simply put the code below at the end of your (child) theme functions.php

By adding required in checkbox input, everyone who wants to access your protected site must tick the checkbox together with entering their password.

add_filter( 'ppw_custom_entire_site_login_form', 'custom_login_form' );
function custom_login_form() 
{
    //Add reCAPTCHA to your password forms (optional)
    $recaptcha_input = PPW_Recaptcha::get_instance()->get_recaptcha_input();
    return '
    <div class="pda-form-login">
    <div>
        <center><img alt="ppwp-logo" src=
"https://passwordprotectwp.com/demo/wp-content/plugins/wp_protect_
password/includes/views/entire-site/assets/ppwp-logo.png" 
style="width:120px;height:120px;"></center>
    </div>
    <form action="?action=ppw_postpass&wrong_password=true" 
method="post">
        <label for="">Password</label>
        <input class="input_wp_protect_password" 
type="password" id="input_wp_protect_password" 
name="input_wp_protect_password">
         <div>
              <input type="checkbox" id="policy" 
name="policy" required value="policy">
                <label for="policy"> I read and accepted the 
<a href="https://passwordprotectwp.com/privacy-policy/">
privacy policy</a></label>
                // When using reCAPTCHA only
                <div style="margin-top: 20px;">'.$recaptcha_input.'</div>
          </div>
          <p id="ppw_entire_site_wrong_password" class="ppw_entire_site_password_error">' . esc_html__( apply_filters( PPW_Pro_Constants::HOOK_CUSTOM_MESSAGE_WRONG_ PASSWORD_ENTIRE_SITE, 'Please enter the correct password!' ), 'password-protect-page' ) . '</p>

        <div>
            <input type="submit" class="button button-primary 
button-login" value="Login">
        </div>
    </form>
</div>
';
}



Now that it’s done, you have successfully added a compulsory checkbox for all customers to confirm their full acceptance of your website’s privacy. Very simple as we promised, isn’t it?

Lasted updated on August 5, 2022