Over a million developers have joined DZone.
Platinum Partner

Set "Remember Me" To Be Always Checked in Wordpress

· Web Dev Zone

The Web Dev Zone is brought to you in partnership with Mendix.  Discover how IT departments looking for ways to keep up with demand for business apps has caused a new breed of developers to surface - the Rapid Application Developer.

The WordPress login page has a checkbox that allows you to always be remembered when you login to WordPress. If you check this box and login successfully to WordPress a cookie will be saved on your computer to let WordPress know that you can bypass the login process.

This makes it really for people who use your site regularly as they won't have to login each time to have access to the admin area of WordPress.

By default the checkbox is always unchecked, so you have to select it each time. I prefer this to checkbox to be selected each time so I don't have to keep clicking on the login page.

Here is a snippet you can add to your functions.php file which will make sure that the checkbox is always checked when you go to the login page.

function login_checked_remember_me() {
	add_filter( 'login_footer', 'rememberme_checked' );
add_action( 'init', 'login_checked_remember_me' );
function rememberme_checked() {
	echo "document.getElementById('rememberme').checked = true;";

The Web Dev Zone is brought to you in partnership with Mendix.  Learn more about The Essentials of Digital Innovation and how it needs to be at the heart of every organization.


Published at DZone with permission of Paul Underwood , DZone MVB .

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}