We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 21792
    • 37 Posts
    I have quite a lot of custom coding and receive information from a 3rd party web service.

    I would like to take this data and create modx web users - can this be done with the api?

    So far I have installed the login module and attempted to pre-populate the register forms - but this only works for real people and requires a confirmation email.

    I have a resource group and access policy working for those who do register with the login plugin but am ideally looking to process the new user request through the API, in ’native’ PHP

    Any (sensible) suggestions will be very much appreciated

      • 18373 ☆ A M B ☆
      • 3,141 Posts
      Evolution, Revolution?
        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.
        • 21792
        • 37 Posts
        Sorry, Revo (Never worked with Evo)

        I didn’t know evo had an API and thought it had died a death
          • 28042 ☆ A M B ☆
          • 24,524 Posts

          ...

          I didn’t know evo had an API and thought it had died a death
          Oooh, I used to wash my boys’ mouth out for saying things like that shocked shocked shocked

          Seriously, since Evo just got a new RC release (1.0.5 RC1) with some really nice new features, it’s very much still alive.
            Studying MODX in the desert - http://sottwell.com
            Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
            Join the Slack Community - http://modx.org
            • 4310
            • 2,310 Posts
            There are still a few of us dinosaurs out there using it wink
              • 3749
              • 24,544 Posts
              This should get you started:

              This will give you a new user:

              $user = $modx->newObject('modUser', array ('username'=>'MyUser'));
              $user->save();
              


              This will give you a user with some stuff in his or her profile:

              $user = $modx->newObject('modUser', array ('username'=>'MyUser'));
              $userProfile = $modx->newObject('modUserProfile');
              $userProfile->set('fullname','My User');
              $userProfile->set('email','[email protected]');
              $success = $user->addOne($userProfile);
              if ($success) {
                  $user->save();
                  return '<p>User object and profile created</p>';
              } else {
                  return '<p>failed to add profile. User not saved.</p>';
              }
              
                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
                • 21792
                • 37 Posts
                what about passwords?

                Or any documentation about adding new users so I don’t have to keep asking questions?

                What’s been provided so far has been of great help - thanks!

                  • 34017
                  • 898 Posts
                  Quote from: sottwell at Jan 12, 2011, 03:20 AM


                  ...

                  I didn’t know evo had an API and thought it had died a death
                  Oooh, I used to wash my boys’ mouth out for saying things like that shocked shocked shocked

                  Seriously, since Evo just got a new RC release (1.0.5 RC1) with some really nice new features, it’s very much still alive.

                  I plan on using Evo for at least 12 more months. It’s faster than Revo and does everything I need (multisite, multi-row tvs). A lot of improvements have come in RC1 of 105 too
                    Chuck the Trukk
                    ProWebscape.com :: Nashville-WebDesign.com
                    - - - - - - - -
                    What are TV's? Here's some info below.
                    http://modxcms.com/forums/index.php/topic,21081.msg159009.html#msg1590091
                    http://modxcms.com/forums/index.php/topic,14957.msg97008.html#msg97008
                    • 3749
                    • 24,544 Posts
                    Quote from: Northie at Jan 12, 2011, 04:00 AM

                    what about passwords?

                    Or any documentation about adding new users so I don’t have to keep asking questions?

                    What’s been provided so far has been of great help - thanks!

                    I think it’s:

                    $user->set('password',md5('somePassword'));


                    At the very bottom of the page here: http://bobsguides.com/revolution-objects.html you’ll find the fields of the user object and the user profile object.
                      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