We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 23166
    • 7 Posts
    I have a little web-server, where I host the websites of my clients. I made a secured area on my website for them, running with modx 2.2.10. There they can find their logins like ftp, sql, etc. I realized this with the login add-on and the profile-snippet. The logins are saved es extended fields for each user. Now to my problem. I also want to save all e-mail accounts from every client, if possible as extended field too. This means i have to add this for each e-mail account per client:
    e-mail-address, e-mail aliases, login-name, login-pass

    Is there a way to set this senseful as extended field?
      • 41592 ☆ A M B ☆
      • 83 Posts
      one solution would be to extend the modUser class, such as, with a xpdoSimpleObject class structured according to your needs. but By the way I wuold wait other opition before examine this solution

      more info http://rtfm.modx.com/revolution/2.x/developing-in-modx/advanced-development/extending-moduser
        Francesco Mussoni | MODX Ambassador | Skype: solidusite2 | Email: [email protected]
        • 16348
        • 64 Posts
        I think the snippet ClientConfig can be a better way to handle this type of situation. I haven't used it by myself but have a look at http://rtfm.modx.com/extras/revo/clientconfig.

        You should be able to save the info in the custom user settings and then show them on a protected resource with the placeholders that are created automatically.

        [Edit] I misunderstood the function of ClientConfig and it is not appropriate for this use case. [ed. note: Kristoffer last edited this post 12 years, 11 months ago.]
          • 23166
          • 7 Posts
          Quote from: solidusite at Oct 24, 2013, 12:13 AM
          one solution would be to extend the modUser class, such as, with a xpdoSimpleObject class structured according to your needs. but By the way I wuold wait other opition before examine this solution

          more info http://rtfm.modx.com/revolution/2.x/developing-in-modx/advanced-development/extending-moduser

          If i try it with modUser, is it possible to add easy more e-mail accounts into the user profile?

          Quote from: Kristoffer at Oct 24, 2013, 02:28 AM
          I think the snippet ClientConfig can be a better way to handle this type of situation. I haven't used it by myself but have a look at http://rtfm.modx.com/extras/revo/clientconfig.

          You should be able to save the info in the custom user settings and then show them on a protected resource with the placeholders that are created automatically.

          I tried it with ClientConfig, but this just works, if i have different contexts, right?


          I think the best solution would be, to load migx into the user profile, where i can add and change e-mail acoounts. But i have no idea, how i could do this, and later, how i could render the accounts to the frontend.
            • 4172
            • 5,888 Posts
            you could create a Custom Manager Page with MIGXdb to manage the User-profiles.
            Than you would just need to put a MIGX-TV-type to the editor-window and store the json into a text-field of the extended userprofile table.

            On the frontend you can use the getImageList-snippet to list the email-accounts of users.
              -------------------------------

              you can buy me a beer, if you like MIGX

              http://webcmsolutions.de/migx.html

              Thanks!
              • 3749
              • 24,544 Posts
              There's no reason you couldn't save the email as an extended field in a plugin attached to OnDocFormSave, though I'm not sure why you'd want to do that since it's easily available in the User Profile.

                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
                • 41592 ☆ A M B ☆
                • 83 Posts
                of course you can, you can make any type of structure you desire. there's a tutorial about it in modx documentation. maybe the first time could be not so simple but once you've understand how do that you can make any related structure with your modUser
                  Francesco Mussoni | MODX Ambassador | Skype: solidusite2 | Email: [email protected]
                  • 4172
                  • 5,888 Posts
                  Quote from: BobRay at Oct 24, 2013, 05:20 PM
                  There's no reason you couldn't save the email as an extended field in a plugin attached to OnDocFormSave, though I'm not sure why you'd want to do that since it's easily available in the User Profile.


                  what he has needed was not one email-field, but datas of multiple email-accounts per user.

                  We created a CMP with MIGXdb now where he can edit all extended fields and used a MIGX-TV-field to manage the mail-accounts per user.
                  No extended - modUser needed. All datas including the mail-accounts are stored into the extended field.

                  Created a custom-update-processor, which has this in it (relevant part of the code):

                              $extended = array();
                  
                              foreach ($data as $key => $value) {
                                  $field = explode('.', $key);
                  
                                  if (count($field) > 1) {
                                      //extended field (json-array)
                                      if ($field[0] == 'Profile_extended'){
                                          $extended[$field[1]] = $value;
                                          unset($data[$key]); 
                                      }
                                  }
                                  elseif(substr($key,0,8) == 'Profile_'){
                                      $data[substr($key,8)] = $value;
                                      unset($data[$key]);    
                                  } 
                  
                              }
                              //$extended['accounts'] = $data['Profile_extended.accounts'];
                              $data['extended'] = $extended;
                  
                              //$data['email'] = $data['Profile_email'];
                              
                  
                              $response = $modx->runProcessor('security/user/update', $data);
                              $checkresponse = true;
                  


                  Think this is a quick an clean solution and easyli extentable.
                  [ed. note: Bruno17 last edited this post 12 years, 11 months ago.]
                    -------------------------------

                    you can buy me a beer, if you like MIGX

                    http://webcmsolutions.de/migx.html

                    Thanks!
                    • 3749
                    • 24,544 Posts
                    Bruno, that looks very good. Is the data being stored in the regular User Profile, or in a custom table?
                      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
                      • 28042 ☆ A M B ☆
                      • 24,524 Posts
                      Looks like it's stored in the user profile -
                      All datas including the mail-accounts are stored into the user_attributes extended field.
                        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