WordPress tips and tricks, wordpress tips

Add Privacy Policy Checkbox in Registration Form

Black Friday Sale - Get 40% Off on all LoginPress Pro Plans - Use Coupon Code

In the middle of building a WordPress website, designing for a particular set of subscribers.  Or just looking to have a friendly way of asking your subscribers to give you consent of agreeing to your policies before landing on your pages? There is a crucial moment of adding a checkbox in the WordPress site.

To make it easy to understand the concept of the WordPress checkbox in the registration form, it must be quoted that it is all related to openly share your Privacy Policy. And requesting the users/subscribers to give you consent for the data you are providing with your WordPress site.

Important*  The WordPress Checkboxes or checkboxes at any website is legal as it is like clicking on a checkbox is urging to a signature on a written contract.

You can customize WordPress built-in user registration page through the use of hooks.

Lets customizing the registration form involves the following hooks:
1. register_form Allow rendering of new HTML element.

// Add privacy policy field.
add_action( 'register_form', 'loginpress_add_privacy_policy_field' );
function loginpress_add_privacy_policy_field() { ?>
    <label for="lp_privacy_policy"><?php _e( 'Privacy Policy', 'loginpress' ) ?><br />
      <input type="checkbox" name="lp_privacy_policy" id="lp_privacy_policy" class="checkbox" />

2. registration_errors Perform validation on form registration fields.

// Add validation. In this case, we make sure lp_privacy_policy is required.
add_filter( 'registration_errors', 'loginpresss_privacy_policy_auth', 10, 3 );

function loginpresss_privacy_policy_auth( $errors, $sanitized_user_login, $user_email ) {

  if ( ! isset( $_POST['lp_privacy_policy'] ) ) :

    $errors->add( 'policy_error', "<strong>ERROR</strong>: Please accept the privacy policy." );
    return $errors;
  return $errors;

3. user_register Save custom form data.

// Lastly, save our extra registration user meta.
add_action( 'user_register', 'loginpress_privacy_policy_save' );

function loginpress_privacy_policy_save( $user_id ) {

  if ( isset( $_POST['lp_privacy_policy'] ) )
     update_user_meta( $user_id, 'lp_privacy_policy', $_POST['lp_privacy_policy'] );

8 thoughts on “Add Privacy Policy Checkbox in Registration Form”

  1. Hey, really helpful , it works!

    Finally can add a real working checkbox, in only 3 steps.

    The pnly thing i would do now is to receive user data registration by mail, including that the user filled the checkbox.

    Anyway, very helpful post !


  2. Thanks a lot for such a precise post. I got clear information on adding Privacy Policy check box in the registration form in a simple and effective way. It is very simple and easy to follow these steps.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.