Created
July 17, 2020 05:02
-
-
Save francosalcedo/59d6f8880019e9d1dd0b517d1c3d7ab0 to your computer and use it in GitHub Desktop.
Login wp admin without password in one file (localhost)
This file contains hidden or 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 __DIR__ . '/wp-load.php'; | |
$username = 'admin'; | |
$user = get_user_by('login', $username ); | |
// Redirect URL // | |
if ( !is_wp_error( $user ) ) | |
{ | |
wp_clear_auth_cookie(); | |
wp_set_current_user ( $user->ID ); | |
wp_set_auth_cookie ( $user->ID ); | |
$redirect_to = user_admin_url(); | |
wp_safe_redirect( $redirect_to ); | |
exit(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment