We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 36632
    • 202 Posts
    Then help me bridge the gap. I'd love to use my creative energy to program simple snippets. I've always liked marrying the creative with the technical. I just don't know how!
      • 36605
      • 70 Posts
      UltraSEF, for one I think it's a much harder thing to learn to program and create the most intuitive and efficient processes for creating a dynamic system. Personally, I'm studying a language called Scheme in a class I'm taking now and I can tell you it's been hugely rewarding (if that's what you meant by bridge the gap!). But I do agree about the importance and share a similar love for the other aspects of development.

      As to the snippet, my problem is not with the idea of looking at his snippet (though I don't know fully know the best way for that besides github. The problem is with my understanding of how the backend creates a user in Revolution. There's parts that I haven't understood that are critical for making the loop work. Besides that, there seem to be other problems but I'm not sure. I was hoping some higher-end dev's who really know ModX might comment and shed some light on the problems. [ed. note: silverman63 last edited this post 14 years, 7 months ago.]
        • 33968
        • 863 Posts
        Most of your answers to this will be in the core/model/modx/processors/ folder, specifically in this case security/user/create.php for pre-2.2, or security/user/create.class.php for 2.2+. This is the processor the manager uses when creating a new user.

        $scriptProperties ($properties for 2.2) is an array containing all the form data posted to the processor when you hit the 'save' button in the manager. Your job really is to load the user data from your csv into this array and then use a variation of the create processor to write the new user to the system using this data.

        I suggested to modify ImportX as it might save you a bit of time working out how to implement the CMP as a nice interface to facilitate importing your users.
          • 33968
          • 863 Posts
          @UltraSEF - why don't you try out a few simple tutorials, w3schools.com might be a good place to start. You don't need to get into the advanced stuff to really make a big impact in MODx. Check out the MODx docs on creating snippets which will help you get code into your web sites.

          Don't be afraid to start up a new thread and ask for some help here too - but persist with it and you'll get there eventually. I'm a designer turned coder myself smiley
            • 36632
            • 202 Posts
            Thanks for the encouragement silverman63 and Lucas.

            I'm reading Chapters 7 & 8 in BobRay's most excellent book. This old dog is very ready to learn new tricks.
              • 18373 ☆ A M B ☆
              • 3,141 Posts
              I actually did a quicky for a client that does just that.. 7 months ago. If only I'd seen this topic in that time! smiley

              I put it up on Gist, except I hit the "Create Private Gist" instead of the "Create Public Gist" button, so it doesn't actually show up in the public list :/

              Aaaanyway: https://gist.github.com/1f3056c2f7897dbe8beb

              There's some comments in there to help you through it. I know there's also a comment that says it's untested, but I've been sharing that link every now and then with people and they've all said it works.. so I guess it does.

              I wonder if it would be nice to update ImportX to allow importing users (that gist does most of the hard work anyway, just need an updated UI that parses CSV to the arrays).. if enough people say they want me to, I might!
                Mark Hamstra • Developer spending his days working on Premium Extras and a MODX Site Dashboard with the ability to remotely upgrade MODX and extras to make the MODX world a little better.

                Tweet me @mark_hamstra, check my infrequent blog at markhamstra.com, my slightly more frequent ramblings at MODX.today or see code at Github.
                • 18373 ☆ A M B ☆
                • 3,141 Posts
                Quote from: okyanet at Feb 14, 2012, 03:44 AM
                Most of your answers to this will be in the core/model/modx/processors/ folder, specifically in this case security/user/create.php for pre-2.2, or security/user/create.class.php for 2.2+. This is the processor the manager uses when creating a new user.


                That does bring to mind the ability of just reusing the processor...

                $user = array(
                  'username' => 'test',
                  'password' => 'omghithere',
                  'fullname' => 'Test User',
                  'email' => '[email protected]',
                );
                $result = $modx->runProcessor('security/user/create',$user);
                if ($result->isError()) {
                  echo $result->getMessage();
                } else {
                  echo 'Created user!';
                }


                $scriptProperties ($properties for 2.2) is an array containing all the form data posted to the processor when you hit the 'save' button in the manager.
                Did that really change in 2.2? Can't remember noticing that, but have been working with 2.2 for a few months now!
                  Mark Hamstra • Developer spending his days working on Premium Extras and a MODX Site Dashboard with the ability to remotely upgrade MODX and extras to make the MODX world a little better.

                  Tweet me @mark_hamstra, check my infrequent blog at markhamstra.com, my slightly more frequent ramblings at MODX.today or see code at Github.
                  • 36632
                  • 202 Posts
                  How does your snippet get the array?
                    • 33968
                    • 863 Posts
                    $scriptProperties ($properties for 2.2) is an array containing all the form data posted to the processor when you hit the 'save' button in the manager.

                    Did that really change in 2.2? Can't remember noticing that, but have been working with 2.2 for a few months now!
                    I might be wrong about that, and not even sure where I got that from now smiley I'm buried in projects dating from pre-2.2 and have barely touched on the new class based processors yet. Gonna try out the new style with the next component I build though.
                      • 18373 ☆ A M B ☆
                      • 3,141 Posts
                      Quote from: ultrasef at Feb 15, 2012, 05:13 AM
                      How does your snippet get the array?

                      That's the part that would have to be customized depending on your need. As long as what you feed to that gist is in the format of that array, the rest should work. Which was the idea of putting that in.

                      In ImportX this process function is called for taking the raw CSV content (stored in $this->data) and parsing that, validating it and returning an array similar to what the user import needs, except for resources of course: https://github.com/Mark-H/importX/blob/master/core/components/importx/processors/prepare/csv.php

                      I'm not sure if a snippet is the best idea in terms of creating an import script, and a CMP like ImportX would probably be easiest.. especially if we want to move it into the extras repository smiley The gist I posted can help people with a quick one-off import though, all they need to do is format their data to the arrays.
                        Mark Hamstra • Developer spending his days working on Premium Extras and a MODX Site Dashboard with the ability to remotely upgrade MODX and extras to make the MODX world a little better.

                        Tweet me @mark_hamstra, check my infrequent blog at markhamstra.com, my slightly more frequent ramblings at MODX.today or see code at Github.