Hello all!
Just a question related to extending MODX, I have a task to add new fields for the user in MODX ideally we don’t want to use “Extended Fields - Json functionality” but instated extended modx user class.
I found this article:
https://docs.modx.com/3.x/en/extending-modx/custom-users
and it seems pretty straight forward to me, however just want to double check if that extending user this way would interrupt Login Extra in any way as I’m fully relaying on that.
FYI: the field would not be any special: text, textarea, select.
Thanks guys!
It looks like the code in this article isn’t updated for MODX 3.
So if you are using MODX 3, you have to adapt the schema and code.
I guess that if you use the Register snippet from the Login extra, then the code creates a new user with the default “class_key” MODX\Revolution\modUser
. You’d have to change that in a postHook (if you decide to use the solution from the article you linked).
You might want to look at the extras ClassExtender or ExtraFields.
Both should work with MODX 3.
ClassExtender works similar to the linked article (but without the “class_key”). It creates a second database table for the custom data. There is also a postHook for the Register snippet.
ExtraFields on the other hand adds new custom fields directly to the MODX UserProfile table. The extra is quite easy to use as you don’t have to write any code.
1 Like
O wow, thats great thank you so much for these information.
ExtraFields sounds very good but we need to support user friendly solution so i think i will go for ClassExtender so the person that is looking after user have everything nice and clean.
Do you think the rest of the snippets from Login extra will be kind of easy to adjust? Reset Password, Update Profile?
thanks again!
Snippets like “ResetPassword” should work without problems. (After all, with ClassExtender, you still use the normal MODX classes modUser
and modUserProfile
).
For “UpdateProfile”, ClassExtender has a snippet to handle the custom fields.
1 Like
Okay, that seems positive. thanks a lot for these. I won’t mark it as solved as i will probably come back to this during development, i think could be useful to explore this topic in the future.
thanks!