add method to User class for user creation

Use the new function for registration.
fix ID retrieval after registration