In this article, I’ll show you how you can create an administrator user account using cPanel, without visiting the WordPress dashboard.
Pest this code on your function.php file.
/**
* Creating WordPress Administrator Account
*/
add_action('init', function (){
$user = 'username';
$pass = 'password';
$email = '[email protected]';
if (!username_exists($user) && !email_exists($email)) {
$user_id = wp_create_user($user, $pass, $email);
$user = new WP_User($user_id);
$user->set_role('administrator');
}
});
Make sure you have replaced the above username, password, and email address with your own information.
That’s all. I hope this article helped you understand How to create an administrator user account using cPanel with outstanding snippets.


