We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 18961 ☆ A M B ☆
    • 237 Posts
    I have two items that I need help with.

    1. I need to add an additional field in the Web User Area - I need to add "Company"

    2. In the same area, ModX requires 6 digits for passwords. My client is moving over more than 600 users and many have less than 6 digits. I would like to remove or reduce the limit.

    Any help would be greatly appreciated.
      Michael Smull
      http://www.bigpixelstudio.com
      twitter: @mdsdesign
      • 4041
      • 788 Posts
      So far I found 3 references to the webuser password length:

      manager/includes/document.parser.class.inc.php
      line 2239

      manager/processors/save_web_user.processor.php
      line 106

      assets/snippets/weblogin/websignup.inc.php
      line ~96


      Create a new plugin named whatever you want, check the following events on the services tab:

      OnWUsrFormRender
      OnWUsrFormSave
      $e = &$modx->Event;
      switch ($e->name) {
      
          // web users
          case 'OnWUsrFormRender':
      
          $company = $modx->db->getRow($modx->db->select("*", $modx->getFullTablename('web_user_settings'), "webuser='".$id."' AND setting_name='company'", "", "1"));
      
          // $_SESSION['webUsrConfigSet']['company'] => Company Name
          echo '
              <table border="0" cellspacing="0" cellpadding="3">
                  <tr>
                      <td nowrap class="warning"><b>Company Name</b></td>
                      <td><input type="text" name="company" class="inputBox" value="'.$company['setting_value'].'"></td>
                  </tr>
              </table>';
          break;
      
          case 'OnWUsrFormSave':
          //$mode
          //$id
          // note that if company input field is cleared during edit and saved, record will automatically be removed from the database
          if($_POST['company'] !=''){
              // check if web user has a setting already in the database
              $c_count = $modx->db->getValue($modx->db->select('count(*)', $modx->getFullTablename('web_user_settings'), 'webuser="-'.$id.'" AND setting_name="company"'));
      
              if($c_count == 1){
              // if a record is found, update the record
                  $fields = array(
                          'setting_value' => $modx->db->escape($_POST['company'])
                          );
                  $update = $modx->db->update($fields, $modx->getFullTablename('web_user_settings'), 'webuser="'.$id.'" AND setting_name="company"');
              }else{
              // insert a new setting for the user
                  $fields = array(
                          'webuser' => $id,
                          'setting_name' => 'company',
                          'setting_value' => $modx->db->escape($_POST['company'])
                          );
              $insert = $modx->db->insert($fields, $modx->getFullTablename('web_user_settings'), 'webuser="'.$id.'"');
              }
          }
          break;
      
          default: '';
          return;
      }


      You should now be able to view/edit the Company Name, found at the bottom of the Photo tab.

      Front end usage:
      $_SESSION['webUsrConfigSet']['company']
        xforum
        http://frsbuilders.net (under construction) forum for evolution
        • 18961 ☆ A M B ☆
        • 237 Posts
        Thanks for the response. I truly appreciate it. I was really hoping to be able to add a company field closer to the rest of the main content. Are there no other ways to add fields in this area?

          Michael Smull
          http://www.bigpixelstudio.com
          twitter: @mdsdesign
          • 4041
          • 788 Posts
          Unfortunately not due to the way the evolution back end is coded, but I did a simple mod to 2 files (manager and web users) which: (1) puts the permissions on a seperate tab, and (2) allows extra settings to be easily added and put on new tabs.

          unzip the attached file, open and copy the contents of the "events_plugin_1.php" file and use that for your plugin code, upload the 2 files found in the manager/actions/folder into the manager/actions/ folder on your site.

          I'll add these mods to the bugtracker and maybe it will be adopted, otherwise these changed files will be kaboshed after an upgrade, so be aware.
            xforum
            http://frsbuilders.net (under construction) forum for evolution
            • 18961 ☆ A M B ☆
            • 237 Posts
            Hi Breezer,

            Thank you for this. First, I did find and change the minimum password length from your above message. That seemed to work fine.

            I added your files and they seem to work as well. Again, not sure this is perfect for what the client wants, but it does get the information into the system.

            Can I ask another question that perhaps you may know. We don't need Fax Number, Mobile Number and a few others. Is there a way to change one of those defaults to Company? Would that be a bad idea if it could be done? I'm using WebLoginPE on the front end and I'm guessing for those signing up on the web, I could easily change the name of that field on the form. It would be changing it in the back end that would be the trick.

            Again, thanks for all of your help on this.
              Michael Smull
              http://www.bigpixelstudio.com
              twitter: @mdsdesign
              • 4041
              • 788 Posts
              I'm not familiar with webloginPE but changing the name of the field in the form should be ok.

              The Phone, Mobile Phone, and Fax fields are varchar with a 100 character limit so to use one of those as Company (mobile_phone in this case), look in the manager/actions/mutate_web_user.dynamic.php starting around line 325.

              Find this part:
              <?php echo $_lang['user_mobile']; ?>


              replace with:
              Company
                xforum
                http://frsbuilders.net (under construction) forum for evolution