Remember Commenters' Details for 30 Days Instead of a Year
Shortens how long the cookies that remember a commenter's name, email and website last, from WordPress's default of one year to 30 days.
Opens WPIDE on
Code
// Days the comment author cookies are kept.
$wpide_comment_cookie_days = 30;
add_filter( 'comment_cookie_lifetime', function () use ( $wpide_comment_cookie_days ) {
return (int) $wpide_comment_cookie_days * DAY_IN_SECONDS;
} );
Notes
Change the number of days to suit your audience; the cookies are only set when the commenter ticks the consent box.
How to add this snippet
- Install WPIDE on your WordPress site (it is free) and open Code Snippets.
- Use snippet above adds it from the library in one click. Or copy the code into a new snippet with the same code type.
- It is added inactive: review the code and settings, then switch it on.