We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 33971
    • 12 Posts
    Foreword: I have done some searching on the forums and it seems that this may just not be in MODX.

    Is there a way of easily assigning photos to MODX users via the manager? Rather than having to build a web user front-end form and handling uploads I was wondering if there something that was missing to handle user images?

    It is because we need to add lots of internal users and against their own blog pages be able to assign their user photo.
      Digital bod.
      • 3749
      • 24,544 Posts
      Are you using Articles for the Blog? It automatically uses Gravatar images based on the user's email address (as does this forum). You set that option on the "Advanced Settings" tab under "Manage Articles."

        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
        • 37110
        • 72 Posts
        You can use gravatar or you install the package modAvatar (http://modx.com/extras/package/modavatar).
          • 33971
          • 12 Posts
          Unfortunately this will not be using Gravatar, they will be portrait head shots that are specific to one website
            Digital bod.
            • 3749
            • 24,544 Posts
            There is a photo field in the user profile. Usually it holds just the path to the image so you can use the Profile snippet and code like this in the page:

            <img src="[[+photo]]" alt="headshot">


            I don't know of any extra that will set the user's photo field when you upload photos, but maybe you could modify the FileUpload snippet to do so.

              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
              • 3749
              • 24,544 Posts
              Looking at the code, I think you could replace the code of line 243 of the FileUpload snippet:


              243 $uploadfile = $path.basename($_FILES['userfile']['name'][$i]);


              with this:

                  $uploadfile = $path.basename($_FILES['userfile']['name'][$i]);
                  $profile = $modx->user->getOne('Profile');
                  if ($profile) {
                      $profile->set('photo', $uploadfile);
                      $profile->save();
                  }
              


              I'm not positive that it would work, but it might be worth a try.

              You'll want to duplicate the FileUpload snippet first, make your changes to the duplicate, and use the duplicate on your page.

              You'll also want to use this property in the snippet tag so there will only be one input field:

              &filefields=`1`
                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
                • 4172
                • 5,888 Posts
                with a quickly created MIGXdb-CMP where you have a user-grid and a form with an image-TV-field that points to the photo-field it would be possible to upload and select a user-photo.
                example:
                https://github.com/Bruno17/migxclientmanager

                if you want to have each user-photo in its own file-directory, this should be possible with a dynamic media-source connected to that image-TV-field.
                  -------------------------------

                  you can buy me a beer, if you like MIGX

                  http://webcmsolutions.de/migx.html

                  Thanks!
                  • 33971
                  • 12 Posts
                  Thanks for your replies.

                  This is as I thought though, that there is nothing that I am missing from the manager. You cannot simply add a photo to a user via the User section of the manager by default, so it has to be a workaround.

                  Hopefully this may get added in a later version.
                    Digital bod.
                    • 37984
                    • 215 Posts
                    Quote from: wiseguydigital at Dec 01, 2013, 09:01 PM
                    Thanks for your replies.

                    This is as I thought though, that there is nothing that I am missing from the manager. You cannot simply add a photo to a user via the User section of the manager by default, so it has to be a workaround.

                    Hopefully this may get added in a later version.

                    This is completely incorrect; as Bruno mentioned above, there is a photo field in the manager:
                      Jesse Couch
                      MODX Aficionado, Front-End Designer & Developer
                      http://www.designcouch.com