2

First of all let me just say that I have only been using Craft for a few months and still has allot to learn about it.

My issue is quite simple in that I have an express server running to display the data on the front-end. I am using Craft as a solution for the client to add or change content on their site. This is working well. I am even able to use your Element API to retrieve data from Craft and together with my Express server I can manipulate and display content where it is needed.

My client has now recently asked me to add a section that would allow users to register users and this is where I am starting to have problems. Or at least, this is where I need some expert knowledge.

I would just like to save the user data via post. I have looked at a few options out there but honestly I don't want to build a plugin to handle this. Is there a way I could post and save data to Craft without it being too complicated?

  • When you say users register users, are you asking about an admin adding users? Or website users themselves registering for an "account" on the site? – RitterKnight Aug 11 '16 at 17:10
2

You'd normally use a front-end form to create users on a Craft site. You can add fields to this form to submit more than the standard set of fields. I believe you could use the same form within your Express app. You are just sending the data via a POST request.

Check the documentation for an example.

  • Hey Luke. Thanks for the advice. Perhaps I don't fully understand the concept of what you are trying to help me with. Firstly, even if I should use the form, where would I point that form to. How would my express server even know where the data needs to go. Also, how would craft even know where and how to save the data. Sorry. I have never had to use a form before for CRAFT. I don't really want to waist time on something thats not really helpfull. – Gevann Mullins Aug 11 '16 at 14:32
  • When you make your request to the Element API you are hitting Craft's files and in turn the database. Your form would have an action URL which runs a controller within Craft to create the new user and add the data. This data would then be retrievable via the Element API. – Luke Pearce Aug 11 '16 at 14:35
  • 2
    I'm saying Craft has already written the functionality, all you need to do is send the data to the action URL users/saveUser craftcms.com/docs/plugins/… – Luke Pearce Aug 11 '16 at 15:30
  • 1
    @GevannMullins: how are you running node.js and calling Craft? ElementAPI is strictly one-dimensional. You can get data but you can't pass it back in. You're basically using Craft like a headless CMS, correct? If you do it that way, that means you need to build some sort of functionality to handle what you're looking to do. In Craft, typically that functionality comes in the form of plugins unless there's a built-in controller action to handle it. – RitterKnight Aug 11 '16 at 17:18
  • 1
    If you're looking for a more RESTful way to get data, you might want to consider using the http messages plugin (which is a newer version of the old restfulapi). – RitterKnight Aug 11 '16 at 17:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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