How to register user programmatically?

emergingdzns - 8 months ago

In my custom store module, I want to be able to register the user that isn't signed in already during the process of checking out if they opt to become a user. I have fields for entering and confirming a password as well as their email address and name etc. But in my handler, I need to tap into the Users Module. But I don't see any repository calls for creating a user, only the form builder handler, which I guess I could copy code from, but I'd rather not duplicate code if I can avoid it. Is there a way to do this? If so, can it be documented somewhere?

ryanthompson - 8 months ago

You can use the UserRepositoryInterface and even the \Anomaly\UsersModule\User\UserActivator if you want to put them into the account confirmation workflow too.