We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 25483
    • 741 Posts
    ronaldlokers Reply #1, 15 years ago
    I want to store extra information with my users, the only option I see is to create extended fields per user.

    How can I add extended fields for every user at once instead of creating them manually for every user?

    This question has been answered by BobRay. See the first response.

      with regards,

      Ronald Lokers
      'Front-end developer' @ h2o Media

    • discuss.answer
      • 3749
      • 24,544 Posts
      In the future, there may be a checkbox for that option when you create an extended field.

      In the meantime, the only alternative would be a utility snippet or plugin, something like this:

      <?php
      $users = $modx->getCollection('modUser');
      
      foreach ($users as $user) {
      
           $profile = $user->getOne('Profile');
           $extendedFields = $profile->get('extended;)
           $extendedFields['newField'] = 'NewValue'; // could be ""
           $profile->set('extended', $extendedFields);
           $profile->save();
      }
        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
        • 25483
        • 741 Posts
        ronaldlokers Reply #3, 15 years ago
        Thx BobRay, I think that it is good enough for what I need at this moment smiley
          with regards,

          Ronald Lokers
          'Front-end developer' @ h2o Media

          • 32699 ☆ A M B ☆
          • 427 Posts
          I assume you know you could add hidden fields in the registration to create these on user creation as well:

                          <input type="hidden" name="januarySpaces" value="" />
                          <input type="hidden" name="januaryTables" value="" />
                          <input type="hidden" name="januaryChairs" value="" />
                          <input type="hidden" name="januaryNeedsElectric" value="" />
                          <input type="hidden" name="januaryMisc" value="" />
            Get your copy of MODX Revolution Building the Web Your Way http://www.sanitypress.com/books/modx-revolution-building-the-web-your-way.html

            Check out my MODX || xPDO resources here: http://www.shawnwilkerson.com