Created
January 7, 2026 18:26
-
-
Save AlbertoBarrago/3f1df5d51b8350d470e63fdb6e3972b0 to your computer and use it in GitHub Desktop.
Emergency Password Reset Script (Locally)
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 | |
| /** | |
| * Emergency Password Reset Script | |
| * | |
| * INSTRUCTIONS: | |
| * 1. Upload this file to your WordPress root directory | |
| * 2. Visit: http://yourdomain.local/reset-password.php in your browser | |
| * 3. Enter your admin username and new password | |
| * 4. DELETE THIS FILE immediately after use! | |
| */ | |
| // Load WordPress | |
| require_once('wp-load.php'); | |
| if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['username']) && isset($_POST['password'])) { | |
| $username = sanitize_text_field($_POST['username']); | |
| $password = $_POST['password']; | |
| $user = get_user_by('login', $username); | |
| if ($user) { | |
| wp_set_password($password, $user->ID); | |
| echo "<h2 style='color:green;'>✓ Password updated successfully for user: " . esc_html($username) . "</h2>"; | |
| echo "<p><strong>IMPORTANT:</strong> Delete this file immediately!</p>"; | |
| echo "<p><a href='" . wp_login_url() . "'>Go to login page</a></p>"; | |
| } else { | |
| echo "<h2 style='color:red;'>✗ User not found: " . esc_html($username) . "</h2>"; | |
| echo "<p>Available users:</p><ul>"; | |
| $users = get_users(); | |
| foreach ($users as $u) { | |
| echo "<li>" . esc_html($u->user_login) . " (ID: " . $u->ID . ")</li>"; | |
| } | |
| echo "</ul>"; | |
| } | |
| exit; | |
| } | |
| ?> | |
| <!DOCTYPE html> | |
| <html> | |
| <head> | |
| <title>Emergency Password Reset</title> | |
| <style> | |
| body { font-family: Arial, sans-serif; max-width: 500px; margin: 50px auto; padding: 20px; } | |
| input { width: 100%; padding: 10px; margin: 10px 0; box-sizing: border-box; } | |
| button { width: 100%; padding: 10px; background: #0073aa; color: white; border: none; cursor: pointer; font-size: 16px; } | |
| button:hover { background: #005177; } | |
| .warning { background: #fff3cd; padding: 15px; border-left: 4px solid #ffc107; margin-bottom: 20px; } | |
| </style> | |
| </head> | |
| <body> | |
| <div class="warning"> | |
| <strong>⚠️ WARNING:</strong> This is a security-sensitive file. Delete it immediately after use! | |
| </div> | |
| <h1>Emergency Password Reset</h1> | |
| <form method="POST"> | |
| <label>Username:</label> | |
| <input type="text" name="username" required placeholder="Enter admin username"> | |
| <label>New Password:</label> | |
| <input type="password" name="password" required placeholder="Enter new password"> | |
| <button type="submit">Reset Password</button> | |
| </form> | |
| </body> | |
| </html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment