Adding "Accept Terms" Checkbox to WordPress Registration Form - ProfilePress

Adding “Accept Terms” Checkbox to WordPress Registration Form

A customer asked us over email if it is possible for him to add an accept terms and conditions checkbox to his WordPress membership registration form which when left unchecked by registering users, prevent WordPress from creating an account for that user. In a nutshell, users account will only be created if they check the checkbox.

In this tutorial, you will learn how to add the checkbox to your front-end registration form and finally, we will provide a code snippet that will ensure the checkbox is checked before the user is registered.

Adding Accept Terms and Condition Checkbox to WordPress Registration Form

Adding the Checkbox to Registration Form

Firstly, create a custom profile field as shown in the picture below.

Adding accept terms and condition checkbox field

To add the custom field to your registration form, add the custom field block if using the drag-and-drop builder.

Add the custom field shortcode if using the advanced shortcode builder by clicking the “Available Shortcode” button in the form builder.

Ensuring Checkbox Is Checked Before Account Registration

To ensure the “accept terms & condition” checkbox is checked before the user account is created, check the “required” checkbox in the block and shortcode settings.

Alternatively, add the code snippet below to your theme’s functions.php file or site specific plugin.

add_filter('ppress_registration_validation', function ($reg_errors, $form_id) {
    if (3 === $form_id) {
        if ( ! isset($_POST['accept_privacy_terms']) || empty($_POST['accept_privacy_terms'])) {
            $reg_errors = new WP_Error('accept_privacy_terms', __( 'You must accept our privacy policy and terms.', 'profilepress' ));

    return $reg_errors;
}, 10, 2);

Note: ensure you change “3” in the code snippet above to the ID of your registration form.