Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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: http://bueltge.de/wordpress-login-unterbinden/1220/
* Description: Set the time that the cookie will be kept at 1 year.
* Version: 0.0.2
* Author: Frank Bültge
* Author URI: http://bueltge.de/
*/
if ( ! function_exists( 'keep_me_logged_in_for_1_year' ) ) {
add_filter( 'auth_cookie_expiration', 'keep_me_logged_in_for_1_year' );
function keep_me_logged_in_for_1_year( $expirein ) {
return 31556926; // 1 year in seconds
}
add_filter( 'login_footer', 'set_default_true_on_checkbox' );
function set_default_true_on_checkbox() {
?>
<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