# Pre-Tick "Save My Name" on the Comment Form

> Ticks the "Save my name, email, and website in this browser" box on the comment form by default, so returning commenters do not retype their details.

- Type: PHP
- Runs: Run everywhere
- Category: [Forms](https://wpide.com/library/category/forms/)
- Tags: comments, cookies, ux
- Author: WPIDE Team
- Installs: 0
- Updated: 2026-10-28
- Page: https://wpide.com/library/form-comment-cookies-checked/

## Code

```php
add_filter( 'comment_form_default_fields', function ( $fields ) {
    if ( isset( $fields['cookies'] ) && false === strpos( $fields['cookies'], 'checked' ) ) {
        $fields['cookies'] = str_replace( 'type="checkbox"', 'type="checkbox" checked="checked"', $fields['cookies'] );
    }

    return $fields;
} );
```

## Notes

Check your privacy rules first; some jurisdictions require consent boxes to start unticked.

## How to use it

Install the free WPIDE plugin (https://wordpress.org/plugins/wpide/), find "Pre-Tick "Save My Name" on the Comment Form" 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/
