On March 26, 2019 we launched new MODX Forums. Please join us at the new MODX Community Forums.
Subscribe: RSS
  • Hi,

    I am allowing my members of a website to update a file they upload to dropbox and storing the filename of the file they upload to their MODx user profile using "UpdateProfile". The file uploading all works fine - but what is not happening is the storing of the new filename of the file they have uploaded being stored to the modUser extended field.

    My upload to dropbox code works on a posthook currently.

    How can I add in my pre/post hook to store the value of the file input "fileName" to the extended field "thisDoc".

    Help!


    Cheers

    dubbs.

    This question has been answered by BobRay. See the first response.

    • Any one got any ideas on this?

      Currently - on profile update - the new file is uploaded nicely, but the "thisDoc" modUser field becomes an array with subsets of file info rather than storing just the filename... Any ideas how to make it just save the filename as a string?

      e.g. it currently saves as below (e.g. it looks like this when you view the extended field in the USER view in the MODx manager):

      thisDoc
      >_ name - example.jpg
      >_ type - image/jpeg
      >_ tmp_name - blah/blah.jpg
      >_ error - 0
      >_ size - 999

      This means - that when you try and call "thisDoc" field back in to a page it displays as blank - rather than showing the filename which is what I want - e.g. should display "example.jpg" i.e. I want to display the first attribute (name) of the container when I call to display [[+thisDoc]] field.

      Any ideas? [ed. note: dubbs last edited this post 4 years, 11 months ago.]
      • Help!!! Anyone??? Please! Desperate to put this site live!

        Thanks guys wink
        • Why is this not working?

          $extended = $profile->get('extended');
          $extended['thisDoc'] = $upload_name;
          $profile->set('extended', $extended);
          $profile->save();
          


          So 'thisDoc' is the extendedField name and $upload_name is the PHP var which contains the filename I want to store in 'thisDoc' extended field... I am calling this on a PostHook...

          Why is it not working???

          I get a server error when I use this approach- logic would say it should work... something I am not understanding somewhere... huh [ed. note: dubbs last edited this post 4 years, 11 months ago.]
          • discuss.answer
            Maybe you don't really have the $profile object and/or the $upload_name. The rest of the code looks fine.

            If it's the current user, you should be able to do this for the profile:

            $profile = $modx->user->getOne('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
            • Quote from: BobRay at Oct 21, 2015, 04:23 AM
              Maybe you don't really have the $profile object and/or the $upload_name. The rest of the code looks fine.

              If it's the current user, you should be able to do this for the profile:

              $profile = $modx->user->getOne('Profile');


              Thanks Bob - seems that was indeed the missing element!!!! Many thanks wink