You probably visit the login page on your WordPress-powered website at least once a week; perhaps one a day. Although WordPress does not include any options to customize the login page to suit your needs or preferences, there are plenty of tutorials and plugins floating around. One of those plugins is Remember Me Checked, a free plugin by WPMU Dev, which automatically checks the ‘Remember Me’ checkbox on the login page. This is useful if you want to help prevent users from loosing their password or provide special options to logged-in users (i.e. a no ad version of your site). While having a plugin is all very well and good and makes it easier for newbie WordPress users, such functionality is easily accomplished with a simple code snippet:
if( ! function_exists( 'remember_me_checked' ) ) :
function remember_me_checked() {
?><script type="text/javascript">// <![CDATA[
function checkit() {
document.getElementById('rememberme').checked = true;
}
window.onload = checkit;
// ]]></script><?php }
add_action( 'login_head', 'remember_me_checked' ); endif;
The snippet adds a script to the login page which will use JavaScript to check the “Remember Me” box. You can add this snippet to your site using my Code Snippets plugin, or (if you insist) by pasting it in your active theme’s functions.php file. Enjoy!