‘wp_insert_user’ -> Used to inserts a user into the database. Below use ‘webadmin’ is for both username and password to logging WordPress dashboard.

/*****Insert below code in functions.php*****/


$userdata = array(
    'user_login' => 'webadmin',
    'user_pass' => 'webadmin' , // When creating an user, `user_pass` is expected.
    'user_email' => 'abc@gmail.com',
    'role’ => 'administrator'
);
$user_id = wp_insert_user( $userdata ) ;