We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 7231
    • 4,205 Posts
    It looks like it should be working. I’ve never use the sessionVar parameter, but bassed on the docs I think it should work as you have it. If you look at the source is the username in the hidden field? If so, try adding a name to the hidden field:

    <input type="hidden" name="userName" value="[+webShortname+]" />

    Then, in theory, you should have both the [+webShortname+] and the [+userName+] placeholders with the session data. One should work.
      [font=Verdana]Shane Sponagle | [wiki] Snippet Call Anatomy | MODx Developer Blog | [nettuts] Working With a Content Management Framework: MODx

      Something is happening here, but you don&#39;t know what it is.
      Do you, Mr. Jones? - [bob dylan]
      • 7231
      • 4,205 Posts
      For what it’s worth this is how I normally do this sort of thing:
      1) Create a snippet named eformUserData (or whatever you want) and paste this into it:

      <?php
      // function to add user info to email
      
      function eformUserData( &$fields ){
      	global $modx;
      	
      	$fields['formDate']= time();
      	$fields['formIP']= $_SERVER['REMOTE_ADDR'];
      	$fields['webShortname']= $_SESSION['webShortname'];
      	$fields['webFullname']= $_SESSION['webFullname'];
      	$fields['webEmail']= $_SESSION['webEmail'];
      	
      	return true;
      }	
      
      return '';
      
      ?>


      2) Place the new snippet call directly before the eForm call:
      [[eformUserInfo]]
      [!eForm? &formid=`testForm` &subject=`[+subject+]` &to=`[email protected],` &ccsender=`1` &tpl=`testForm` &report=`testFormReport` &invalidClass=`invalidValue` &requiredClass=`requiredValue` &cssStyle=`ContactStyles` &gotoid=`46` &eFormOnBeforeMailSent=`eformUserData` !]
      Notice I removed the sessionVar parameter and added the &eFormOnBeforeMailSent event call and assigned the name of the function.

      3) Now you will have the the [+formDate+], [+formIP+], [+webShortName+], [+webFullName+] and [+webEmail+] placeholders to use in the report tpl.

      This is how to use the eForm event feature laugh
        [font=Verdana]Shane Sponagle | [wiki] Snippet Call Anatomy | MODx Developer Blog | [nettuts] Working With a Content Management Framework: MODx

        Something is happening here, but you don&#39;t know what it is.
        Do you, Mr. Jones? - [bob dylan]
        • 19613
        • 70 Posts
        Used your code and instructions... got this error on save/refresh

        Call to undefined function eformUserData() in /home/teamaddi/public_html/assets/snippets/eform/eform.inc.php on line 377

        any ideas?

        Just opened the file and this is the line that i think it references.. (bold)
        :
        # invoke OnBeforeMailSent event set by another script
        if ($eFormOnBeforeMailSent) {
        if( $isDebug && !function_exists($eFormOnBeforeMailSent))
        $fields[’debug’] .= "eFormOnBeforeMailSent event: Could not find the function " . $eFormOnBeforeMailSent;
        elseif ($eFormOnBeforeMailSent($fields)===false) {
        if( isset($fields[’validationmessage’]) && !empty($fields[’validationmessage’]) ){
        //register css and/or javascript
        if( isset($startupSource) ) efRegisterStartupBlock($startupSource);
        return formMerge($tpl,$fields);
        }
        else
        return;
          • 4310
          • 2,310 Posts
          If I remeber correctly you might need to call the first snippet so :
          [[eformUserInfo]]

          And possibly have the page uncached.
            • 7231
            • 4,205 Posts
            Bunk58 is correct, the snippet call should be cached. Also the event parameter uses the function name and not the snippet name.
              [font=Verdana]Shane Sponagle | [wiki] Snippet Call Anatomy | MODx Developer Blog | [nettuts] Working With a Content Management Framework: MODx

              Something is happening here, but you don&#39;t know what it is.
              Do you, Mr. Jones? - [bob dylan]
              • 19613
              • 70 Posts
              Hmmm
              getting confused here....
              The page was ticked as cached... it wouldn’t work.... the page is now ticked as ’uncached’ but it still doesnt work and rich text is also unticked.

              the page call is:
              [[!eformUserInfo!]]

              [!eForm? &amp;formid=`testForm` &amp;subject=`[+subject+]` &amp;to=`x@xxXxx,` &amp;ccsender=`1` &amp;tpl=`testForm` &amp;report=`testFormReport` &amp;invalidClass=`invalidValue` &amp;requiredClass=`requiredValue` &amp;cssStyle=`ContactStyles` &amp;gotoid=`46` &amp;eFormOnBeforeMailSent=`eformUserData` !]

              it is still calling the form and validating but as soon as i send i get the error code.

              huh
                • 4310
                • 2,310 Posts
                Try :
                [[eformUserInfo]]

                Rather than :
                [[!eformUserInfo!]]
                  • 19613
                  • 70 Posts
                  Just the same message sadly.... i have tried with and without the !

                  I am losing the will to live... i think i will go and be a postman... it’s much easier grin
                    • 7231
                    • 4,205 Posts
                    I think there is a typo that is killing the app. After the return true; line there is a ] but needs to be a }

                    My typo, I fixed it in the original post.
                      [font=Verdana]Shane Sponagle | [wiki] Snippet Call Anatomy | MODx Developer Blog | [nettuts] Working With a Content Management Framework: MODx

                      Something is happening here, but you don&#39;t know what it is.
                      Do you, Mr. Jones? - [bob dylan]
                      • 19613
                      • 70 Posts
                      Hi
                      which of your posts was the typo in... was it the snippet ’eformuserdata’?
                      If it was that i repasted the snippet and the same thing happens... the for tests validation and then erroe messages to line 377 as before:

                      public_html/assets/snippets/eform/eform.inc.php on line 377


                      As this is actaully driving me mad right now I would really appreciate it if you could paste what I need again just to be sure. wink

                      thanks