We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 16861 ☆ A M B ☆
    • 86 Posts
    What is the best way to add 1400 usernames and passwords to a 2.1.8 site and assign it to a user role and user group?
      Lee Brinckley
      Manassas, VA (Washington DC)
      Twitter - @leebrinckley
      http://www.leebrinckley.com
      • 3749
      • 24,544 Posts
      Definitely a custom snippet. The form depends on the structure and content of your CSV file, but heart of the user creation part would look something like this:

      <?php
      /* CreateUsers Snippet */
      $fields = array();
      $roleId = '12';
      $userGroupName = 'SomeUserGroup';
      
      /* the following code would go in a loop */
      
      /* Get a CSV line and parse it here */
      $fields['username']  = $username;
      $fields['password'] = $password;
      $fields['role'] = $roleId;
      $fields['active'] = '1'; // (if you want them active)
      $user = $modx->newObject('modUser', $fields);
      $user->joinGroup($userGroupName);
      $user->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
        • 16861 ☆ A M B ☆
        • 86 Posts
        BobRay - Thank you! This puts me in the right direction.
          Lee Brinckley
          Manassas, VA (Washington DC)
          Twitter - @leebrinckley
          http://www.leebrinckley.com