# Terms and Privacy Checkbox on Registration

> Adds a required "I agree to the terms and privacy policy" checkbox to the WordPress registration form and records when each user agreed.

- Type: PHP
- Runs: Run everywhere
- Category: [Users](https://wpide.com/library/category/users/)
- Tags: users, registration, privacy
- Author: WPIDE Team
- Installs: 0
- Updated: 2026-10-28
- Page: https://wpide.com/library/registration-terms-checkbox/

## Code

```php
// URL of your terms page (the privacy policy page is linked automatically when set).
$wpide_terms_url = home_url( '/terms/' );

add_action( 'register_form', function () use ( $wpide_terms_url ) {
    $privacy = get_privacy_policy_url();
    ?>
    <p style="margin-bottom:16px">
        <label>
            <input type="checkbox" name="wpide_accept_terms" value="1" <?php checked( ! empty( $_POST['wpide_accept_terms'] ) ); ?>>
            I agree to the <a href="<?php echo esc_url( $wpide_terms_url ); ?>" target="_blank" rel="noopener">terms of use</a>
            <?php if ( $privacy ) : ?>and the <a href="<?php echo esc_url( $privacy ); ?>" target="_blank" rel="noopener">privacy policy</a><?php endif; ?>.
        </label>
    </p>
    <?php
} );

add_filter( 'registration_errors', function ( $errors ) {
    if ( empty( $_POST['wpide_accept_terms'] ) ) {
        $errors->add( 'wpide_terms', '<strong>Error:</strong> Please accept the terms to create an account.' );
    }

    return $errors;
} );

add_action( 'user_register', function ( $user_id ) {
    if ( ! empty( $_POST['wpide_accept_terms'] ) ) {
        update_user_meta( $user_id, 'wpide_terms_accepted', current_time( 'mysql' ) );
    }
} );
```

## Notes

Covers the default wp-login.php registration form; shop or membership plugins have their own forms.

## How to use it

Install the free WPIDE plugin (https://wordpress.org/plugins/wpide/), find "Terms and Privacy Checkbox on Registration" in its snippet library and add it in one click; or create a new PHP snippet in WPIDE (or any code snippets plugin) and paste the code above. More snippets: https://wpide.com/library/
