Enable WordPress Dashboard Quick Login

All of the web browsers today have input autocomplete or auto-fill feature built-in and chances are that you have your WordPress username and password stored in the browser and the input fields are completed automatically upon visiting /wp-login.php. Wouldn’t it be nice if WordPress would log you in automatically if the fields have been pre-filled by the browser?

Here is a simple snippet of PHP and Javascript that checks if the input fields have been filled and submits the login form one second after the page has been loaded. All you have to do is append #quicklogin to your login bookmark URL so that it looks like http://example.com/wp-admin/#quicklogin and Javascript will do its magic. Add this to your functions.php.

add_action('login_footer', 'enable_admin_quick_login');
function enable_admin_quick_login() {
?>
	<script type="text/javascript">
		$url_hash = window.location.hash;
		if ($url_hash.indexOf('quicklogin') != -1) {
			setTimeout(function() {
				if (document.loginform.user_login.value && document.loginform.user_pass.value) {
					document.loginform.submit();
				}
			}, 1000);
		}
	</script>
<?php
}

Leave a Reply