Skip to content

Instantly share code, notes, and snippets.

@lewayotte
Last active July 24, 2017 23:44
Show Gist options
  • Save lewayotte/6b15f8bb7d4df8f93b98 to your computer and use it in GitHub Desktop.
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
<?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