Skip to content

Instantly share code, notes, and snippets.

@bueltge
Last active January 4, 2023 10:39
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bueltge/4433308 to your computer and use it in GitHub Desktop.
Save bueltge/4433308 to your computer and use it in GitHub Desktop.
WordPress Plugin, that set the time that the cookie will be kept at 1 year and active the 'Rember Me' Checkbox for default
<?php
/**
* Plugin Name: Keep me Logged In for 1 Year
* Plugin URI: https://bueltge.de/wordpress-login-unterbinden/1220/
* Description: Set the time that the cookie will be kept at 1 year.
* Version: 0.0.3
* Author: Frank Bültge
* Author URI: https://bueltge.de/
*/
! defined( 'ABSPATH' ) && exit;
// Filters the duration of the authentication cookie expiration period.
add_filter( 'auth_cookie_expiration', function( $expirein ) {
return 31556926; // 1 year in seconds
} );
// Fires in the login page footer.
add_filter( 'login_footer', function() {
?>
<script type="text/javascript">
document.getElementById( 'rememberme' ).checked = true;
document.getElementById( 'wp-submit' ).focus();
</script>
<?php
} );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment