Skip to content
General Revolution Evolution Add-ons International
Login | Register | MODX.com
MODX Open Source Content Management System, Framework, Platform and More.
Find a Partner | Hosts + SaaS | Jobs | Donate
  • RegisterSign Up with the MODX Community
  • LoginUse Your MODX.com Account
  • MODX Community Forums
  • Add-ons
  • Users, Authentication & Personalization
  •  
  • importing usernames and passwords from a csv file into a 2.1.8 site#

  • 16861
    49

    Lee Reply #1, 5 months, 3 weeks ago

    Reply
    • Link to this post#1
    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?


  • 3749
    11,692
    PLEASE, PLEASE specify the version of MODX you are using . . . PLEASE!

    MODx info for everyone: http://bobsguides.com/MODx.html

    BobRay Reply #2, 5 months, 3 weeks ago

    Reply
    • Link to this post#2
    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();
    


  • 16861
    49

    Lee Reply #3, 5 months, 3 weeks ago

    Reply
    • Link to this post#3
    BobRay - Thank you! This puts me in the right direction.





Actions

Login to Post

Other Support Options

To file a bug or make a feature request visit our issue tracker, or you can also purchase commercial support.

Love MODX?

If you build sites for a living with MODX or just love using it, why not give back?

Information

Posted in this thread:
BobRay, LeeB

 
Back to Top

MODX Global HQ

1333 N Stemmons Fwy, Ste 110
Dallas, TX 75207
United States

+1 (469) 777-MODX (6639)

The MODX Company

  • Contact
  • Media Center
  • Careers at MODX
  • Wall of Fame
  • The MODX Blog

Sponsors

SoftLayer Firehost: Secure Cloud Hosting

Stay Connected

Read our previous email newsletters.

Twitter Facebook Google+ LinkedIn github Feeds

Privacy Policy | Terms of Service | Pixels by AKTA Web Studio© 2005-2012 MODX. All rights reserved. Trademark Policy