Last active
July 24, 2017 23:44
-
-
Save lewayotte/6b15f8bb7d4df8f93b98 to your computer and use it in GitHub Desktop.
mu-plugin to log in as any WordPress user without a known password
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 | |
/* | |
* **** WARNING: THIS IS VERY INSECURE - DELETE AFTER USE **** | |
* | |
* This will let you log in as any WordPress user if you know their user ID. This is for support only! | |
* | |
* Stick this file in the wp-content/mu-plugins directory | |
* Browse to http://domain.tld/?user_id=USER_ID | |
* You'll be logged in as that user! | |
* | |
* **** WARNING: THIS IS VERY INSECURE - DELETE AFTER USE **** | |
*/ | |
function secret_user_login() { | |
if ( !empty( $_GET['user_id'] ) ) { | |
wp_set_current_user( $_GET['user_id'] ); | |
wp_set_auth_cookie( $_GET['user_id'] ); | |
} | |
} | |
add_action( 'init', 'secret_user_login' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment