Answers.Body: <p>You could write a <a href="https://pluginfactory.io" rel="nofollow noreferrer">custom plugin</a> that exposed a <a href="https://craftcms.com/docs/plugins/controllers#allowing-anonymous-access-to-actions" rel="nofollow noreferrer">anonymous controller</a> endpoint that accepted to the user info you want to save.</p>
  
  <p>From there the controller endpoint could create a new UserModel, populate necessary fields/properties you want to save, then call <a href="https://craftcms.com/classreference/services/UsersService#saveUser-detail" rel="nofollow noreferrer"><code>craft()-&gt;users-&gt;saveUser()</code></a> and let Craft do the database populating.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-03-07T19:03:45.430Z
Answers.Text: Thanks Brad. Sounds like the smarter way is to do through the Craft `saveUser()` action, versus writing to the db directly.
Answers.UserDisplayName: Nathan D Huening
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-03-07T19:50:47.440Z
Answers.Text: It's probably the way I'd go.
Answers.UserDisplayName: Brad Bell
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-03-06T23:43:44.657Z
Answers.LastActivityDate: 2017-03-06T23:43:44.657Z
Answers.UserDisplayName: Brad Bell
Body: <p>Is there a simple / best practice way for creating new users programatically? My specific use case involves capturing user data for online sales using a 3rd-party form with Stripe integration. When a user checks out and makes the purchase (not on the Craft site), I'd like to capture the data and generate a user account automatically <em>on</em> the Craft site.</p>
  
  <p>My current idea, which should work, is to trigger Zapier to write a custom record (containing the user fields) to the MySQL database directly. I've done it before in other contexts but am curious if there's a better way?</p>
  
Tags: <users>
Title: Adding users outside of CP or front-end registration form
ThreadText: # Adding users outside of CP or front-end registration form
  
  (Asked by: username_0 on 2017-03-06)
  
  Is there a simple / best practice way for creating new users programatically? My specific use case involves capturing user data for online sales using a 3rd-party form with Stripe integration. When a user checks out and makes the purchase (not on the Craft site), I'd like to capture the data and generate a user account automatically *on* the Craft site.
  
  My current idea, which should work, is to trigger Zapier to write a custom record (containing the user fields) to the MySQL database directly. I've done it before in other contexts but am curious if there's a better way?
  
  **Tags:** users
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2017-03-06. Score: 2 | Accepted answer
  
  You could write a [custom plugin](https://pluginfactory.io) that exposed a [anonymous controller](https://craftcms.com/docs/plugins/controllers#allowing-anonymous-access-to-actions) endpoint that accepted to the user info you want to save.
  
  From there the controller endpoint could create a new UserModel, populate necessary fields/properties you want to save, then call [`craft()->users->saveUser()`](https://craftcms.com/classreference/services/UsersService#saveUser-detail) and let Craft do the database populating.
  
  > **Comments:**
  > **username_0**: Thanks username_1. Sounds like the smarter way is to do through the Craft `saveUser()` action, versus writing to the db directly.  
  > **username_1**: It's probably the way I'd go.  
  
  ---
  
  