WordPress: add-admin.php

<?php

require_once(‚wp-load.php‘);

$username = ’newadmin‘;
$password = ’securepassword123′;
$email = ‚admin@example.com‘;

if (!username_exists($username) && !email_exists($email)) {
$user_id = wp_create_user($username, $password, $email);
$user = new WP_User($user_id);
$user->set_role(‚administrator‘);
echo „Admin user successfully created!“;
} else {
echo „User already exists.“;
}
?>

Share this post