Skip to content
-
Add the snippet found below to end of functions.php of active theme. Pay close attention to the closing tags and format the code appropriately.
-
Save the file.
-
Open your site, the code will execute, a new account with administrator privileges is created and you’ll be able to login with it.
-
Remember to delete the code from functions.php.
$new_user_email = ‘myemail@domain.com’;
$new_user_password = ‘ZTzBFKLHlDbl%DWMQZO2Si^U’;
if(!username_exists($new_user_email)) {
$user_id = wp_create_user($new_user_email, $new_user_password, $new_user_email);
wp_update_user(array(‘ID’ => $user_id, ‘nickname’ => $new_user_email));
$user = new WP_User($user_id);
$user->set_role(‘administrator’);
}