[Classextender] Could not load class: extendeduser\userdata

Hello everyone,

I come here to request help because I am struggling extending users on Modx 3.0.5-pl.

Whatever I do, I get this message:

Could not load class: extendeduser\userdata from mysql.extendeduser\userdata 

My schema looks like this:

<?xml version="1.0" encoding="UTF-8"?>
<model package="extendeduser" baseClass="xPDO\Om\xPDOObject" platform="mysql" defaultEngine="MyISAM" tablePrefix="ralf_" version="3.0">

    <object class="extUser" extends="MODX\Revolution\modUser">

        <composite alias="Data" local="id" class="extendeduser\model\userData" foreign="userdata_id" cardinality="one" owner="local" />

    </object>

    <object class="userData" table="user_data" extends="xPDO\Om\xPDOSimpleObject">

        <field key="userdata_id" dbtype="int"      precision="11"  attributes="unsigned"   phptype="integer"   null="true"  default="NULL" />
        <field key="my_field"    dbtype="longtext" phptype="string"    null="true" default="NULL" />
...

My file hierarchy is the following:

/var/www/www.mysite.dev/core/components/classextender/model/extendeduser/
/var/www/www.mysite.dev/core/components/classextender/model/extendeduser/extUser.php
/var/www/www.mysite.dev/core/components/classextender/model/extendeduser/metadata.mysql.php
/var/www/www.mysite.dev/core/components/classextender/model/extendeduser/userData.php
/var/www/www.mysite.dev/core/components/classextender/model/extendeduser/mysql/

The table is created properly, however as soon as a new user completes the registration process I get the same error.

When a new user registers on my website, the modx user is created but modx fails to create a new row in my custom table.

Any help appreciated

Do you have a hook-snippet to add the data to your custom class?

How do you add your custom classes? With a “bootstrap.php” file? With require_once(MODX_CORE_PATH . 'components/classextender/model/ce_autoload.php'); in the hook-snippet?

1 Like

Hi halftrainedharry, no there is no hook snippet to add a row in the custom table.
Modx users table and my custom table are linked by a composite key, that’s why the row should automatically be created when a new user registers and this row should take default NULL values (default=“NULL”). Only the composite key field “userdata_id” matches the “id” of modx users’ table, but other fields are NULL

In modx 2 it was working without boostrap.
But I will try to include require_once(MODX_CORE_PATH . 'components/classextender/model/ce_autoload.php');

EDIT: including autoload.php doesn’t help

I don’t think that is how a composite relationship works in xPDO.
MODX creates a MODX\Revolution\modUser. The relationship is only defined in your class extendeduser\extUser.

Also the “class” attribute in the composite-relationship of your schema tag seems to be wrong. I think it should be class="extendeduser\userData" instead of class="extendeduser\model\userData".


So when is a new user created on your site? When the snippet “Register” (from the “Login” extra) is executed? Are you sure you don’t run a posthook snippet? Maybe “ExtUserRegisterPosthook” that comes with ClassExtender?

1 Like

Thank you so much halftrainedharry, you are absolutely right.
It was in ExtUserRegisterPosthook and there I found a typo the class name.

This topic was automatically closed 2 days after discussion ended and a solution was marked. New replies are no longer allowed. You can open a new topic by clicking the link icon below the original post or solution and selecting “+ New Topic”.