Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save hamedmoody/d519ed43ff77e00606e7ada1b70bd869 to your computer and use it in GitHub Desktop.
Save hamedmoody/d519ed43ff77e00606e7ada1b70bd869 to your computer and use it in GitHub Desktop.
<?php
/**
* 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