One of the biggest mistakes that I feel that Drupal has made is that it is difficult for non-administrators to create accounts for other users. While at first blush this seems appropriate, there are many, many valid reasons that users should be able to create accounts on behalf of other people. The problem is that, in all versions of Drupal (at least 5-8) there is a call to
drupal_goto() inside the form generation function that is executed unless the user has the "
administer users" permission.
This is bad! I actually feel that this is a defect, in that the code should not perform a redirect when generating a form! Returning nothing would be much preferred!
That being said, I have had 3 sites in as many months that needed the functionality of one individual (not an administrator) creating an account for another user. The general method presented here is not without difficulty, as you may have to do other altering of the form in order to get it to do everything that you want it to, but the code shown here will provide the basic functionality.