Woocommerce

Add Privacy Policy Concent on WooCommerce Account Registration Form

European Union’s new GDPR law requires clear user consent to store personal information, so users can have more personal control over their data stored on websites.

Do you want to Add Privacy Policy Concent on WooCommerce Account Registration Form? European Union’s new GDPR law requires clear user consent to store personal information, so users can have more personal control over their data stored on websites.

In this article, we will show you how to easily create GDPR compliant WooCommerce Account Registration Form.

What is Required to Make a Form GDPR Compliant

In order to make your WordPress forms GDPR compliant, you will need to add the following features:

  1. Ask users to give explicit consent for storing and using their personal information.
  2. Allow users to request access to their own personal information stored on your website.
  3. Allow users to request deletion of their data from your website.

In spite of that, let’s take a look at how to easily create GDPR compliant WooCommerce Registration forms.

How to Make a GDPR Compliant WooCommerce Account Registration Form

You need to add the following snippet to your active theme’s functions.php file.

If you are not comfortable touching theme’s file or don’t know what you are doing, Pretty Please use code snippets plugin.

/**
 * @snippet       Add Privacy Policy Checkbox on WooCommerce Account Registration Form
 * @how-to        Read tutorial @ https://wpglorify.com/?p=35564
 * @sourcecode    https://wpglorify.com/?p=35564
 * @testedwith    WooCommerce 3.4
 */
 
add_action( 'woocommerce_register_form', 'wpglorify_add_registration_privacy_policy', 11 );
   
function wpglorify_add_registration_privacy_policy() {
  
woocommerce_form_field( 'privacy_policy_reg', array(
    'type'          => 'checkbox',
    'class'         => array('form-row privacy'),
    'label_class'   => array('woocommerce-form__label woocommerce-form__label-for-checkbox checkbox'),
    'input_class'   => array('woocommerce-form__input woocommerce-form__input-checkbox input-checkbox'),
    'required'      => true,
    'label'         => 'I\'ve read and accept the Privacy Policy',
)); 
  
}
  
// Show error if the user does not tick
   
add_filter( 'woocommerce_registration_errors', 'wpglorify_validate_privacy_registration', 10, 3 );
  
function wpglorify_validate_privacy_registration( $errors, $username, $email ) {
    if ( ! (int) isset( $_POST['privacy_policy_reg'] ) ) {
        $errors->add( 'privacy_policy_reg_error', __( 'Privacy Policy consent is required!', 'woocommerce' ) );
    }
return $errors;
}

After you add the code snippet to your theme’s functions.php file you will see a checkbox on the registration form.

However, If the user doesn’t check the privacy box they will see the following error.

uncheck error

I hope this article helped you learn how to easily Add Privacy Policy Consent checkbox on WooCommerce Account Registration Form.

Do you have any Question? Please let me know in the comments below.

Show More

Related Articles

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.

Close
Close