How to auto login wordpress | How to login wordpress admin without password

In this article, I will show you how you can set up automatic login to a specific user. This way you can access to any username exist in your WordPress site. Suppose you are trying to access to a user and that’s

username is ‘admin’. Now just place this codes in your theme’s functions.php

function auto_login() {
	if (!is_user_logged_in()) {
	//determine WordPress user account to impersonate
	$user_login ='admin';
	//get user's ID
	$user = get_userdatabylogin($user_login);
	$user_id = $user->ID;
	wp_set_current_user($user_id, $user_login);
	do_action('wp_login', $user_login);


Then go to your browser and open your website and reload it. Yes ! You are now logged in as admin.

If you want to access to another username then just change the variable $user_login to your desired username.

Remember !

This is a Terrible thing as all your visitor will get access to your admin dashboard. Do this only for testing purpose. You can restrict it by sending some value through the URL and retrieve those as $_GET[] method to prevent getting access by all visitors.