We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 34193
    • 330 Posts
    ok me again I’ve got my user creation working but the users are also extended so I’m struggeling to understand how to do this in conjunction with runProcessor

    so my code first the issue is commented inside
    <?php
            $parentRes = $this->modx->runProcessor('security/user/create', array(
                        'username' => $_POST['firstname'] . $_POST['surname'],
                        'fullname' => $_POST['firstname'] . ' ' . $_POST['surname'],
                        'address' => $_POST['address1'],
                        'city' => $_POST['address2'],
                        'state' => $_POST['address3'],
                        'zip' => $_POST['postcode'],
                        'phone' => $_POST['phonenum'],
                        'mobilephone' => $_POST['mobilenum'],
                        'email' => $_POST['email'],
                        'newpassword' => TRUE,
                        'passwordnotifymethod' => 'e',
                        'passwordgenmethod' => 'g',
                        'class_key' => 'ParentExtUser',
                    ));
            /*  Above creates user np */
    
            if ($parentRes->isError()) {
                if ($parentRes->hasFieldErrors()) {
                    $fieldErrors = $parentRes->getAllErrors();
                    $errorMessage = implode("\n", $fieldErrors);
                } else {
                    $errorMessage = 'An error occurred: ' . $parentRes->getMessage();
                }
                return ($errorMessage);
            }
    
            $this->Parent = $parentRes->getObject(); /*This line seems to return an array not an object */
    
            $this->extendedParent = $this->modx->newObject('parentExtras');
            $this->extendedParent->set('priority',$_POST['priority']);
            $this->extendedParent->set('title',$_POST['title']);
            /* Above creates a new object based on extended schema np and sets it's variables */
    
            $this->Parent->addOne($extendedParent); /* Returns the error [b]Call to a member function addOne() on a non-object[/b] */
            $this->Parent->save();
    ?>
    


    So I guess my question is how do I grab the user I have just created as a new object without having to do a new db call ?
      • 34193
      • 330 Posts
      ok guess this is something similar to what BobRay found in this post http://modxcms.com/forums/index.php/topic,58224.msg333678.html#msg333678 when creating resources.