Created
October 22, 2017 20:13
-
-
Save CapWebSolutions/fae44d2e8ebaa4d03fe600a1f108a5f3 to your computer and use it in GitHub Desktop.
WordPress emergency admin
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 | |
| /** | |
| * Ref: https://kuttler.eu/en/code/wordpress-emergency-admin/ | |
| * Upload to wp-content/mu-plugins/whichevernameyoulike.php | |
| */ | |
| $login = 'foobar'; # New username | |
| $password = 'barbaz'; # Password for the new user | |
| $email = '[email protected]'; # Email address of the new user | |
| $ip = '127.0.0.1'; # Insert your IP, http://google.com/search?&q=what%20is%20my%20ip | |
| if ($_SERVER['REMOTE_ADDR'] === $ip) { | |
| require_once(ABSPATH . WPINC . '/pluggable.php'); | |
| require_once(ABSPATH . 'wp-admin/includes/' . 'user.php'); | |
| $userdata = array( | |
| 'user_login' => $login, | |
| 'user_pass' => $password, | |
| 'user_email' => $email, | |
| 'role' => 'administrator', | |
| ); | |
| $user_id = wp_insert_user($userdata); | |
| var_dump($user_id); | |
| die('delete me!'); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment