-
☆ 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?
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();
-
☆ A M B ☆
- 86 Posts
BobRay - Thank you! This puts me in the right direction.