We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 34193
    • 330 Posts
    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.
      • 28215
      • 4,149 Posts
      Did you try:

      $response = $modx->runProcessor('security/user/create',array(
         'username' => $hook->getValue('firstname').$hook->getValue('surname'),
         /* ... */
         'extended' => array(
            'fieldname' => 'value', /* etc */
         ),
      ));
        shaun mccormick | bigcommerce mgr of software engineering, former modx co-architect | github | splittingred.com
        • 34193
        • 330 Posts
        Thanks shaun,
        Is there a last of parameters for most of the processors anywhere yet, I had a look around and couldn’t find one. The ones used I found digging around in the code and running through debug with various breakpoints.

        I just feel that the built in processors are such a great tool.
          • 28215
          • 4,149 Posts
          There’s not yet; runProcessor made it into 2.0.7, and we’d love to get them documented, but for now, until we get the time to doc it, you’ll have to use the code.
            shaun mccormick | bigcommerce mgr of software engineering, former modx co-architect | github | splittingred.com