We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 47154
    • 6 Posts
    I have successfully extended modUser with a custom class and added a table with custom data. I can access the data as expected via a snippet on the front-end, however, I continue to get an error when loading the data to the manager form. It seems executing
    $modx->addPackage('packagename','path/to/package/model');
    fails when running in a custom class. The only way I can even create a new instance of my class is by first manually including the mysql class files. The error I am receiving when doing so is the following:

    [2015-08-24 23:25:00] (ERROR @ /assets/components/dealerportalusers/connector.php) Could not get table name for class: Dpuserdata
    [2015-08-24 23:25:00] (ERROR @ /assets/components/dealerportalusers/connector.php) No foreign key definition for parentClass: Dealerportaluser using relation alias: Dpuserdata

    Is there some other way to load my class so I can create new records similar to the addProfile() method in the modUserCreateProcessor? Below is the addUserdata() method I have created that causes the errors. Any insights would be appreciated.

    public function addUserdata() {
    		require_once MODX_CORE_PATH.'components/dealerportalusers/model/dealerportalusers/mysql/dpuserdata.class.php';
    		//$this->modx->addPackage('dealerportalusers',MODX_CORE_PATH.'components/dealerportalusers/model/');
    		$this->userdata = $this->modx->newObject('Dpuserdata');
    		$this->userdata->fromArray($this->getProperties());
    		$this->object->addOne($this->userdata,'Dpuserdata');
    		return $this->userdata;
    	}
      • 3749
      • 24,544 Posts
      Did you generate class and map files for your custom class? That's necessary for your code to work.

      You might consider ClassExtender, which will do most of the work for you and help you add the fields to the Create/Edit User form.
        Did I help you? Buy me a beer
        Get my Book: MODX:The Official Guide
        MODX info for everyone: http://bobsguides.com/modx.html
        My MODX Extras
        Bob's Guides is now hosted at A2 MODX Hosting
        • 47154
        • 6 Posts
        Yes, I did generate the class and map files, but I guess it's possible I missed something or configured something wrong there. I had not seen that ClassExtender plugin before. I'll take a look at that. Thanks for the help.