Created
October 11, 2023 01:32
-
-
Save Rajinsharwar/0e0264be1967bddce1cd90117e410306 to your computer and use it in GitHub Desktop.
A WordPress auto-login php script. Upload this file anywhere in your website, and simply login by visiting the file from your browser. For example, if you upload this file in your ROOT, visit "http://your-domain.com/auto-login.php" to automatically login to your WordPress dashboard.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
require_once('wp-load.php'); | |
$loginusername = 'admin'; //Replace your username for which user you want to login. | |
$user = get_user_by( 'login', $loginusername ); | |
$user_id = $user->ID; | |
wp_set_current_user( $user_id, $loginusername ); | |
wp_set_auth_cookie( $user_id ); | |
do_action( 'wp_login', $loginusername, $user ); | |
wp_redirect( admin_url() ); | |
unlink(__FILE__); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Alternate solution: