Lee Reply #1, 5 months, 3 weeks ago
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?
<?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();