We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 34162
    • 1 Posts
    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.
      • 7231
      • 4,205 Posts
      I think that this can be accomplished with a plug-in without any hacking, but this would be beyond my experience. There are these Web user events to tie into via a plugin:

      Web Users
      OnBeforeWUsrFormDelete
      OnBeforeWUsrFormSave
      OnWUsrFormDelete
      OnWUsrFormPrerender
      OnWUsrFormRender
      OnWUsrFormSave
        [font=Verdana]Shane Sponagle | [wiki] Snippet Call Anatomy | MODx Developer Blog | [nettuts] Working With a Content Management Framework: MODx

        Something is happening here, but you don't know what it is.
        Do you, Mr. Jones? - [bob dylan]
        • 34162
        • 1 Posts
        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.
          • 7231
          • 4,205 Posts
          Maybe you could use jQuery (or other JS) to rename / hide / reorganize the existing fields. The same as ManagerManager does for the content fields. Just an idea grin
            [font=Verdana]Shane Sponagle | [wiki] Snippet Call Anatomy | MODx Developer Blog | [nettuts] Working With a Content Management Framework: MODx

            Something is happening here, but you don&#39;t know what it is.
            Do you, Mr. Jones? - [bob dylan]
            • 4749
            • 623 Posts
            Yes, I like this idea. It would definitely save you from hacking it up. A plugin to customize webuser fields - sounds like a winner!
              The MODx has you...
              Utah Web Design
              • 29667
              • 4 Posts
              I’m trying to add custom user fields to the Web Users Manager area in MODx Evolution 1.0 via a custom plugin. I’m in the early stages and can’t get the ’OnWUsrFormRender’ hook to do anything. Any ideas?

              Here’s my test plugin code:
              <?php
              $e = &$modx->Event;
              switch($e->name){
                  case "OnWUsrFormRender":
                      $fields = '
                          Test Info: <input type="text" name="test"/>
                      ';
                      $e->output($fields);    //this doesn't show up
                      echo 'testing';    //this doesn't show up
                      break;
              }
              ?>


              (PS- I’ve tried WebUserPE and PPP, but neither of them are good for my situation...)
                • 28042 ☆ 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).
                  Studying MODX in the desert - http://sottwell.com
                  Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
                  Join the Slack Community - http://modx.org
                  • 3749
                  • 24,544 Posts
                  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.
                    Did I help you? Buy me a beer
                    Get my Book: MODX:The Official Guide
                    MODX info for everyone: http://bobsguides.com/modx.html
                    My MODX Extras
                    Bob's Guides is now hosted at A2 MODX Hosting
                    • 39519 ☆ A M B ☆
                    • 79 Posts
                    Quote from: BobRay at Dec 02, 2010, 12:56 AM
                    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.

                    BOB! Do you know of any pre-built plugins that do this? I am in the middle of a coding nightmare trying to get this functionality. I just want my extended fields to show up on the Manager's User Form
                      Mat Dave Jones