Hello,
In the Manager under Security->Manage Users and Manage Web Users, I notice that there is a very basic form where an administrator can fill in contact information such as a mobile phone number, fax number, email address, etc. One of the things I need to do for my client is provide them with a much more complex staff directory. I’d like to hook into the existing Web Users and Manager Users sections in the manager since they seem to provide a nice base, but I’m not sure how to customize those fields. I’d of course also need to have several new database tables to hold the information, since I don’t want to modify any of the core tables.
I found the file [tt]manager/actions/mutate_web_user.dynamic.php[/tt] that has HTML and SQL hard-coded everywhere with no object orientation to speak of. Since there’s no class that I can hook into and override, I’m not quite sure how to go about doing this, barring manually hacking the core files myself (which, again, I do not want to do with MODx Revolution around the corner). Is this the correct file to be looking at? Maybe it’s just a legacy file and the real user settings manager form is located elsewhere? I’d really appreciate any insight or direction anyone could provide.
Ahh yes that looks like a good start! Thank you for pointing those out to me. I was thinking about a plug-in initially but dismissed the idea because I needed to make a lot of interface changes and not strictly functional changes. I didn’t realize there were interface-centric events that I could hook into.
[tt]OnWUsrFormPrerender[/tt] would let me add fields to the beginning of the form, and [tt]OnWUsrFormRender[/tt] would let me add fields after, but I also need to be able to change the ones that already exist (even if that means removing them entirely and then re-creating them elsewhere) so everything fits into the design of the new form properly. The first method I can think of is adding a [tt]<div style="display:none">[/tt] at the end of the PreRender output and [tt]</div>[/tt] to the beginning of the post-Render output to hide those fields, but that really seems like a messy hack.
Yes, I like this idea. It would definitely save you from hacking it up. A plugin to customize webuser fields - sounds like a winner!
-
☆ A M B ☆
- 24,524 Posts
Unfortunately the action files for the Manager are not built in such a way that you can simply add or remove fields. They are HTML with inline PHP, and each field is echo’ed as it’s written, rather than being gathered into a variable or array like the $modx->documentObject is for working with resources. The plugins for these action pages can only deal with the page before the forms are begun, and after they are generated.
<form action="index.php?a=89" method="post" name="userform">
<?php
// invoke OnWUsrFormPrerender event
$evtOut = $modx->invokeEvent("OnWUsrFormPrerender",array("id" => $user));
if(is_array($evtOut)) echo implode("",$evtOut);
?>
... the form is generated with HTML and inline PHP here ...
<?php
// invoke OnWUsrFormRender event
$evtOut = $modx->invokeEvent("OnWUsrFormRender",array("id" => $user));
if(is_array($evtOut)) echo implode("",$evtOut);
?>
</form>
That’s why ManagerManager was developed; it inserts a lot of javascript into the page to work with the DOM in the browser. However, MM as it is only works with the resource editing page (manager/actions/mutate_content.dynamic.php). You might be able to extend it to work with another action page, such as the web user editing page (manager/actions/mutate_web_user.dynamic.php).
You might consider MODx Revolution, which has the option of adding "extended" fields in the user profile table. The fields are easy to access with xPDO and you can add them to the end of the user form with a fairly simple plugin.