WordPress emergency admin
I received an emergency call from a client, his WordPress site didn't work. None of the logins either. Well, here's another script to the rescue if all you have left is an ftp login or some other way to upload files. It will create a new admin user with the credentials you specify. Upload this file to the wp-content/mu-plugins/ directory, create it if necessary. The script will only run if you enter your IP address, and you will have to delete the script after it has created the new user.
<?php
/**
* Upload to wp-content/mu-plugins/whichevernameyoulike.php
*/
$login = 'foobar'; # New username
$password = 'barbaz'; # Password for the new user
$email = 'you@example.com'; # 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!');
}
19 comments
Reply