I am running Revo 2.0.7-pl(traditional), Windows 7, PHP 5.3.3, MySQL 5.1.50 on my local machine.
I want to add users via a php script that takes its input from a csv file.
I am receiving this error when setting up $modx->newObject(’modUser’):
Fatal error: Class ’modPrincipal’ not found in C:\Server\Sites\modxtest\core\model\modx\moduser.class.php on line 7
Why is core\model\modx\modPrincipal.class.php not found?
Thanks for your assistance.
Here is the code:
<?php
//
// Input Roster.csv format:
// username, password, fullname, mobilephone, phone, email
//
require_once '../../config.core.php';
include_once MODX_CORE_PATH . 'model/modx/modx.class.php';
$modx= new modX();
//
require_once('parsecsv.lib.php'); # Include the parseCSV class
$csv = new parseCSV(); # Create a new parseCSV object
$csv->delimiter = ","; # Use the comma delimiter
$csv->enclosure = '"'; # Use the double quotes enclosure
$csv->parse('Roster.csv'); # Parse the Roster.csv
//
foreach ($csv->data as $key => $row) {
while ($row[username] !== "") {
/* Setup the user */
$user = $modx->newObject('modUser', array('username'=>$row[username]));
$user->set('active','1');
$user->set('password',md5($row[password]));
/* Setup the user's profile */
$profile = $modx->newObject('modUserProfile');
$profile->set('fullname', $row[fullname]);
$profile->set('email', $row[email]);
$profile->set('phone', $row[phone]);
$profile->set('mobilephone', $row[mobilephone]);
$user->addOne($profile);
/* save the user to DB */
$user->save();