Last active
January 4, 2023 10:39
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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