Keep "Remember Me" Logins for 30 Days
Extends the login cookie to 30 days when "Remember Me" is ticked. Sessions without it keep the normal two-day lifetime.
Opens WPIDE on
Code
add_filter( 'auth_cookie_expiration', function ( $expiration, $user_id, $remember ) {
return $remember ? 30 * DAY_IN_SECONDS : $expiration;
}, 10, 3 );
Notes
Change 30 to the number of days you want.
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.