1

Has anyone saved JSON in a custom member field? I have a big array I'd like to tie to member registration. I'm using the User module to register. Thoughts?

  • Can you elaborate more on your concerns or what isn't working for you? JSON is just plain text and therefor could be saved in a textarea. I have never used User (as I save my members as channel entries) but I don't see why it wouldn't work. The real question is what you plan to do with that JSON and where you wish to display that field. – Justin Kimbrell Apr 30 '13 at 0:55
1

That was exactly what I needed to do, just didn't think about it at the end of the day. Building the JS object onClick of the button, then filling a textarea prior to submit. Thanks for the point in the right direction.

| improve this answer | |
0

What we did was wrote a, extension and handle the hook that updated the entry and added it there.

This was for BrilliantRetail and we needed to add JSON to a field for each product when being added to the cart.

| improve this answer | |
0

I just did this, and although my situation was pretty unique, hopefully it still helps.

In my situation, I needed to add lots of data from a template, and I wanted to use Freemember to easily save it as a custom field. Here were the steps:

  1. Created a simple "dummy" html form with all the necessary inputs, independent of Freemember, with no form action or onClick event (just a form tag, inputs, and a submit button).

  2. Created a separate (hidden) form with one hidden field that's set up via Freemember's {exp:freemember:update_profile ...} tag. This field is set to submit to my custom member field, and has an empty value attribute. This is what actually gets submitted.

  3. When the dummy form is submitted, I used jQuery's amazing .serializeArray() method to collect all the dummy form data into a nice js object, and then a really simple json-jquery plugin to turn that into a proper JSON string.

  4. Once I have my json string from all the form fields, I use it to populate my Freemember form's hidden input tag, and trigger it's submission.

Keep in mind, for most cases this is a sloppy approach. Building a proper extension / module and implementing solid validation is likely the way to go. For someone like me who's way quicker in JS than EE Extension Development, this was a nice workaround. At the very least, hopefully this approach brings other methods to light =).

Best of luck!

| improve this answer | |

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.