Hi I am trying to write a snippet that will take a users details from a FormIt form and add them as a modx user. I have this mostly working using the following code
$response = $modx->runProcessor('security/user/create',array(
'username' => $hook->getValue('firstname').$hook->getValue('surname'),
'fullname' => $hook->getValue('firstname').' '.$hook->getValue('surname'),
'address' => $hook->getValue('address1'),
'county' => $hook->getValue('address2'),
'city' => $hook->getValue('address3'),
'zip' => $hook->getValue('postcode'),
'phone' => $hook->getValue('phonenum'),
'mobilephone' => $hook->getValue('mobilenum'),
'email' => $hook->getValue('email'),
'newpassword' => TRUE,
'passwordnotifymethod' => 'e',
'passwordgenmethod' => 'g',
));
if ($response->isError()) {
if ($response->hasFieldErrors()) {
$fieldErrors = $response->getAllErrors();
$errorMessage = implode("\n",$fieldErrors);
} else {
$errorMessage = 'An error occurred: '.$response->getMessage();
}
$hook->addError('error_message',$errorMessage);
return false;
}
return true;
What I can’t work out is how to create extended fields within the profile, as the form has some additional fields that I would like to store as extended fields.