Save user consent using a custom registration form

You are here:

We offer consent on the WordPress default registration page. This is not enough for users that have a custom registration form. Not collecting user consent on registration is bad for you and will also create a strange experience for your users because after registration and the first login they will see a screen saying that the privacy policy was updated and that they need to agree to it. What about other possible consent that is required? You get the point.

How to implement this with your customized form

You need to render the checkboxes and then save its contents right after the user has been saved to the database.

To render the checkboxes you can use GDPR::consent_checkboxes().

When you save the user to the database using your custom logic, you can call

GDPR::save_user_consent_on_registration( $user_id ) to automatically save the consent to the database and log this information to the audit log.

Important: This function must be called after the user has been saved to the database and assigned a user ID to it.

You can read more about these and other functions here: Functions & Shortcodes

Code Sample

Sample form

<form method="post">
  <label for="first_name">First Name</label>
  <input type="text" name="first_name" id="first_name" value="" placeholder="">
  <label for="last_name">Last Name</label>
  <input type="text" name="last_name" id="last_name" value="" placeholder="">
  <label for="email">E-mail</label>
  <input type="email" name="email" id="email" value="" placeholder="">
  <label for="password">Password</label>
  <input type="password" name="password" id="password" value="" placeholder="">
  <?php GDPR::consent_checkboxes(); ?>
  <input type="submit" name="" value="Register">


// Your custom code and validations. Everything else in your registration logic.

$userdata = array(
  'user_login'  =>  'login_name',
  'user_pass'   =>  NULL,  // When creating a user, `user_pass` is expected.
  // more fields. You can learn more at

$new_user = wp_insert_user( $userdata );
GDPR::save_user_consent_on_registration( $new_user );