I've got a subscription-only site I'm developing where certain fields outside of those provided by modUser are needed. I've temporarily used extended fields for custom data such as: company, subscription_start (date), subscription_term, etc. I find this too fragile a way of handling the input (i.e., it's too easy to delete not only important data, but the data field all together), and it's a bit unintuitive for the client. Ideally this data would be able to be added within the general information tab ... perhaps even splitting out the subscription criteria on its own tab.
Also to be considered is that a component is being built to allow users to register for trial access to the site using a special registration code. These codes are to be given out to specific prospects (or groups of prospects), having varying expiration dates and the ability to restrict the number of times a code can be used (seats). So, my front-end login will need to check for the status of the user (are they a regular user or are they a they a trial user?). If they are a trial user, their associated code will be checked against for validity.
All this background is given because I'm grappling with the idea of extending modUser. I've read that it sometimes more appropriate to just add a custom table (but am not sure how you'd cascade changes [i.e., deletions] made in the modUser table). What's the best route?
extending the modUser with an additional table is the best option in your situation.
composite - joined records of your extended-table will get automatically deleted, when user-records are deleted, as long as you are working with xpdo for all actions.
If it was me, I would build my own usermanagement-CMP with help of MIGXdb.
Thanks for the input. My next question: Is it possible to build on top of (or somehow extend) the built-in user editing form to add my custom fields, or do I really need to replicate what exists and add to that (under a new menu item)?
[ed. note: smg6511v2 last edited this post 13 years ago.]
It's possible to add new fields to the user form with a plugin tied to OnUserFormRender. It's very easy to add them at the end of the form, though theoretically, you could inject them anywhere with a little extra code.
You can save them in a plugin tied to OnUserFormSave.
Shameless Plug: There's an example of both in my book (p. 492):
http://amzn.to/Qfsl1Z
I'm back to focusing on this subject ... next, is it possible to alter the initial manage users page (without hacking core files)? I'd be looking at adding one or two of my extended user fields and removing the id listing.
Thanks for the reply. BTW, Bob's book is unavailable (and has been for a while) from Amazon. Anyone know if another batch is being produced?
Here's a simple example for a MIGXdb-CMP, which can manage modUsers.
You can simply configure your own form within the MIGX-configurator.
-
☆ A M B ☆
- 24,524 Posts
You can get BobRay's book from other sources, such as Barnes and Noble
http://www.barnesandnoble.com/w/modx-bob-ray/1106819231?ean=9780983619406
There is another book available by W. Shawn Wilkerson as well, that is also quite good.
http://www.amazon.com/MODX-Revolution-Building-Management-Framework/dp/0985853204