Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save CapWebSolutions/fae44d2e8ebaa4d03fe600a1f108a5f3 to your computer and use it in GitHub Desktop.

Select an option

Save CapWebSolutions/fae44d2e8ebaa4d03fe600a1f108a5f3 to your computer and use it in GitHub Desktop.
WordPress emergency admin
<?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