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?

1 Answer 1


You could write a custom plugin that exposed a anonymous controller 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() and let Craft do the database populating.

  • Thanks Brad. Sounds like the smarter way is to do through the Craft saveUser() action, versus writing to the db directly. Mar 7, 2017 at 19:03
  • It's probably the way I'd go.
    – Brad Bell
    Mar 7, 2017 at 19:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.