$modx->setOption(xPDO::OPT_SETUP); $user = $modx->newObject('modUser', array( 'username' => $username, 'password' => $password, 'sudo' => 1, )); $profile = $modx->newObject('modUserProfile', array( 'email' => $email, )); $user->addOne($profile); $user->save();