Skip to content

Instantly share code, notes, and snippets.

@dkrusky
Created March 13, 2016 23:48
Show Gist options
  • Save dkrusky/53bb8d593ecc049e5afa to your computer and use it in GitHub Desktop.
Save dkrusky/53bb8d593ecc049e5afa to your computer and use it in GitHub Desktop.
Login to WordPress as administrator (or any other user) without knowing the username or password.
<?php
include('wp-config.php');
$user_id = 1; // Default admin user id. (usually the first user entered into the database)
$remember = 1; // Remember Session (14 days approx)
$secure = (!isset($_SERVER['HTTPS']) || $_SERVER['HTTPS'] != 'on') ? 0 : 1; // Use SSL
// Force authorization as the above user without password
wp_set_auth_cookie( $user_id, $remember, $secure );
header('location: ./wp-admin/');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment