As a follow up to my post on how to create a user account in Drupal 6 programmatically, I ran into a situation where I needed to do this in Drupal 7. Pretty similar but a few differences. So here you go:
//This will generate a random password, you could set your own here$password= user_password(8); //set up the user fields$fields=array('name'=>'user_name','mail'=>'user_name@example.com','pass'=>$password,'status'=>1,'init'=>'email address',