We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 20865
    • 30 Posts
    How I can work with objects?
    There are extra fields that can be filled with any information from the profile or register form, but date is stored as an object and I don’t know how to get it.
    Please help me to avoid lamo-code with inserting extra-fields to a table =)
      • 3749
      • 24,544 Posts
      Which version of MODX?
        Did I help you? Buy me a beer
        Get my Book: MODX:The Official Guide
        MODX info for everyone: http://bobsguides.com/modx.html
        My MODX Extras
        Bob's Guides is now hosted at A2 MODX Hosting
        • 20865
        • 30 Posts
        MODx Revolution 2.0.5-pl (traditional)
        *but datA is stored...
          • 3749
          • 24,544 Posts
          We need more information about exactly what you’re trying to do before we can help you.

          What kind of date field do you mean (resource field, user field, user extended field, TV ?).

          What do you want to do with the date field once you get it (e.g., display it, use it in a calculation, use it as a snippet property)?

            Did I help you? Buy me a beer
            Get my Book: MODX:The Official Guide
            MODX info for everyone: http://bobsguides.com/modx.html
            My MODX Extras
            Bob's Guides is now hosted at A2 MODX Hosting
            • 20865
            • 30 Posts
            modx_user_attributes has extended collumn that stores data in some format like
            {"parent_name":"\u0412\u044f\u0447\u0435\u0441\u043b\u0430\u0432\u043e\u0432\u043d\u0430","document":"\u043f\u0441\u043f","document_create":"","number":"21414441","date_create_document":"","ICQ":"","Skype":"","webmoney_ru":"5332545452154","yandexmoney":"","banks":"","sent":"true","login-updprof-btn":" \u0420\u0435\u0434\u0430\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043f\u0440\u043e\u0444\u0438\u043b\u044c "}

            probably it is JSON format, but I’m not sure.
            And Login.Profile works with this field when you activate extra-fields.
            So I need to read\write from\to this field in order to work properly with Login.Profile and modX.
            How can I do this?
              • 3749
              • 24,544 Posts
              It is JSON format, but you don’t need to mess with it because MODX will do the conversion for you automatically. You want something like this (assuming that you want to change the extended field(s) for the current user):

              $profile = $modx->user->getOne('Profile');
              $extFields = $profile﷓>get('extended');
              $extFields['fieldName'] = 'value';
              $profile﷓>set('extended',$extFields);
              $profile-﷓>save();


              If you need to get a number of users and change extended fields for all of them or for another specific user, you’ll need to give more details.
                Did I help you? Buy me a beer
                Get my Book: MODX:The Official Guide
                MODX info for everyone: http://bobsguides.com/modx.html
                My MODX Extras
                Bob's Guides is now hosted at A2 MODX Hosting
                • 20865
                • 30 Posts
                Thanks for help.