I don’t know the structure of your new table and what relationship it has with the ’users’ table, but for example you could define an aggregate type relationship like this:
<object class="CustomClass" table="custom_table" extends="xPDOSimpleObject">
<field key="customKey" dbtype="int" precision="10" phptype="integer" null="false" default="" />
. . .
<aggregate alias="User" class="modUser" local="customKey" foreign="id" cardinality="one" owner="foreign" />
</object>
You’ll need to run
xPDOGenerator to create php classes and maps for the schema you created, so that you can use them within modx.
You’ll then be able to use something like the following to grab, for example, a username related to a particular field in your custom table:
<?php
$custom = $modx->getObject('CustomClass',1); // where '1' is the value of 'customKey'
$userid = $custom->getOne('User');
return $userid->get('username');
You can look in
core/model/schema/modx.mysql.schema.xml to see how existing relationships (and classes) are defined for modx tables.
I can’t go into the level of detail in the documentation, but if you’re still unsure about this feel free to post more info about your custom table and which user field you want to use as a foreign key.