We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!

Answered Member Resources

    • 40088
    • 708 Posts
    Revo 2.3.2

    Members can register using the [[!Register]] snippet then create new resources with NewsPublisher.

    To list all resources created by the logged-in user (in the secure member area) I'm using,
    [[!getResources? 
        &parents=`[[~2]]` 
        &where=`{"createdby:=":[[!+modx.user.id]]}`
        &tpl=`memberResources`
    ]]

    The problem: Resources created by the super admin are listed fine, however member-created resources are not being displayed at all.

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

      Todd
    • discuss.answer
      • 42562
      • 1,145 Posts
      I have the same feature, and I get your expected result using similar code

      [[!getResources?
      &parents=`783,791,1314` //I have actual numbers here
      &includeTVs=`1`
      &where=`{"createdby:=":[[!+modx.user.id]]}`
      &limit=`0`
      &showHidden=`1`
      &tpl=`myPublished`]]

      Hope this helps
        TinymceWrapper: Complete back/frontend content solution.
        Harden your MODX site by passwording your three main folders: core, manager, connectors and renaming your assets (thank me later!)
        5 ways to sniff / hack your own sites; even with renamed/hidden folders, burst them all up, to see how secure you are not.
        • 40088
        • 708 Posts
        donshakespeare, thank you so much.

        I feel like an idiot. I'm pretty sure it was the missing &showHidden that was the problem.

        I've been looking for a tutorial on how to allow a logged-in member to edit and/or delete their previously created resources. Do you know of any? [ed. note: todd.b last edited this post 11 years, 9 months ago.]
          Todd
          • 42562
          • 1,145 Posts
          Glad that one helped.


          To list all resources created by the logged-in user (in the secure member area) I'm using,
          I am guessing you are generating a list of published articles displayed on a page(not necessarily created by the user but by you, say, published-articles.html), and this page is then viewed by the user author?
          Well if that's the case, [[*createdby]] will always show the creator of the page, namely the Super Admin..

          Try [[+createdby]]

          As for extended fields, you are better off writing a three-line code to fix your issue
          Look at
          https://forums.modx.com/thread/?thread=52689&i=1&page=1
          https://forums.modx.com/thread/95652/getting-a-user-s-object-by-user-id-i-d-like-to-know-how-it-s-done#dis-post-517727
          and of course http://bobsguides.com/revolution-objects.html
            TinymceWrapper: Complete back/frontend content solution.
            Harden your MODX site by passwording your three main folders: core, manager, connectors and renaming your assets (thank me later!)
            5 ways to sniff / hack your own sites; even with renamed/hidden folders, burst them all up, to see how secure you are not.
            • 40088
            • 708 Posts
            Scratch that, I spoke too soon. I will check out your suggestion above. Thanks again.

            Also, how do you allow your members to edit their previously created resources with, I presume, NewsPublisher?
              Todd
              • 42562
              • 1,145 Posts
              I wrote a snippet called [[!whoPublished]], that displays the NewPublisher button always to the Admin, and to respective author.

              If they land on the page from goodness me knows where:
              $output = '';
              $modxID = $modx->user->get('id'); //get id of the present viewer
              $modxResource = $modx->resource->get('createdby'); //get id of the creator of the page (not publisher), because sometimes, I let them create, but let the Admin publish.
              if ($modxID == $modxResource || $modxID == 1) { //if  id of present user matches the id of the author OR  Sudo Admin is viewing the page (id of 1)
              $output = '[[!NpEditThisButton?  &np_id=`123`&noShow=`129`]]';
              }
              return $output;

              If you have multiple NPbuttons, say, in a getResources call, just do it as prescribed in the tut.
              In the tpl [[!NpEditThisButton? &np_id=`123` &np_edit_id=`[[+id]] `]]
                TinymceWrapper: Complete back/frontend content solution.
                Harden your MODX site by passwording your three main folders: core, manager, connectors and renaming your assets (thank me later!)
                5 ways to sniff / hack your own sites; even with renamed/hidden folders, burst them all up, to see how secure you are not.
                • 3749
                • 24,544 Posts
                @donshakespeare: very nice! wink

                @todd.b: You probably know this by now, but your initial problem was the &parents=`[[~2]]`, that would send the URL of resource 2 and &parents wants resource ID numbers.
                  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
                  • 40088
                  • 708 Posts
                  @BobRay Thanks for the tip. So many simple things to trip me up.

                  @donshakespeare I'm using your snippet and I'm being redirected to the NP form (from a member-created page that lives outside of the members area/folder) but all the NP form fields are empty.
                    Todd
                    • 3749
                    • 24,544 Posts
                    Try adding this property to the NpEditThisButton tag:

                    &np_edit_id=`[[*id]]`
                      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
                      • 40088
                      • 708 Posts
                      I added it to the NpEditThisButton tag in the whoPublished snippet but no luck.
                        Todd