We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 38538
    • 30 Posts
    Hi,
    i'm trying to pass an argument to a custom hook snippet from the page where the form sits. In this case, i need to pass the user id logged in my page (i get all the user's fields from the Profile snippet) to my custom hook (called newsp_create). I tried like so but i think it is not the right way:

    [[!FormIt?
       
       &hooks=`newsp_create,redirect`
       &redirectTo=`6`
       &validate=`name:required,
          tag:required:stripTags
       &userid=[[+id]]
       
    ]]
    

    i use $userid inside my newsp_create snippet for referring to that &userid, but the variable seems empty. Any suggestion? [ed. note: mau1989 last edited this post 12 years, 2 months ago.]
      • 3749
      • 24,544 Posts
      Try this:

      &userid=`[[+modx.user.id]]`



      ---------------------------------------------------------------------------------------------------------------
      PLEASE, PLEASE specify the version of MODX you are using . . . PLEASE!
      MODX info for everyone: http://bobsguides.com/modx.html
        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
        • 38538
        • 30 Posts
        It worked with
        [[+id]]
        and previous
        [[!Profile]]
        snippet call smiley
          • 3749
          • 24,544 Posts
          Quote from: mau1989 at Feb 18, 2012, 11:05 AM
          It worked with
          [[+id]]
          and previous
          [[!Profile]]
          snippet call smiley

          That might be a little slower, since it will set all fields of the user object as placeholders. I think this would speed it up a little:

          [[!Profile? &useExtended=`0`]]



          ---------------------------------------------------------------------------------------------------------------
          PLEASE, PLEASE specify the version of MODX you are using . . . PLEASE!
          MODX info for everyone: http://bobsguides.com/modx.html
            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
            • 38538
            • 30 Posts
            Quote from: BobRay at Feb 18, 2012, 08:35 PM
            Quote from: mau1989 at Feb 18, 2012, 11:05 AM
            It worked with
            [[+id]]
            and previous
            [[!Profile]]
            snippet call smiley

            That might be a little slower, since it will set all fields of the user object as placeholders. I think this would speed it up a little:

            [[!Profile? &useExtended=`0`]]




            ---------------------------------------------------------------------------------------------------------------
            PLEASE, PLEASE specify the version of MODX you are using . . . PLEASE!
            MODX info for everyone: http://bobsguides.com/modx.html

            I need the extra field too! But thanx for the tip wink
            Anyway, i am getting some serious troubles i described in this post
            http://forums.modx.com/thread/74369/setting-object-field-in-formit-hook-doesn-t-works
            If someone can help will be very apreciated.