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

    I have a custom hook like this:
    
    <?php
    $datestamp = date('Y-m-d H:i:s');
    $hook->setValue('datestamp', $datestamp);
    
    
    $ebat = $hook->getValue('UD2');
    $ebat = (int)$ebat;
    
    ....
    ....
    code with some calculate stuff
    ....
    ....
    
    
    
    $hook->setValue('ergebnisM3', $e3);
    $hook->setValue('ergebnisM4', $e4);
    
    return true;
    


    The part with the date stamp thing is copied from the MODx manuel.

    In the e-Mail chunk I placed this:

    
    ....
    ....
    E1: [[+ergebnisM3]]
    E2: [[+ergebnisM4]]
    
    Date: [[+datestamp]]
    
    


    But, when I get the mail with the content. Alle the fields that are set in the hook via setValue are displayed as
    [[+ergebnisM3]]
    [+ergebnisM4]]
    [[+datestamp]]
    and not with the values. The other values that comes direct from the form are OK.

    I tested the execute of my custom hook like they told me in the manuel:

    <?php
    $modx->log(xPDO::LOG_LEVEL_ERROR,'Testing my custom hook.');
    return true; //<-- if you omit this or return false, your form won't validate

    The hook is executing.
    What can it be? [ed. note: ichris89 last edited this post 8 years, 5 months ago.]
      • 4172
      • 5,888 Posts
      what is your formit-call?
      did you place your hook before the email-hook?
        -------------------------------

        you can buy me a beer, if you like MIGX

        http://webcmsolutions.de/migx.html

        Thanks!
        • 49710
        • 92 Posts
        Hi,

        
        [[!FormIt?
           &hooks=`spam,email,redirect,formItAutoResponder,customCalculate`
           &emailTpl=`myMail`
           &emailTo=`[email protected]`
           &redirectTo=`110`
           &validate=`email:email:required,
        			 name:required`
           &fiarToField=`email`
           &fiarTpl=`mailcontent`
           &fiarSubject=`Test`
           &fiarFromName=`Testdomain`
          
        
        ]]
        
        


        My hook is:
        customCalculate
          • 49710
          • 92 Posts
          Thank you, your hint gave me the way to the solution:
          Now I placed the Hook before the email hook. Now it works.

          Thank you.
            • 4172
            • 5,888 Posts
            also, the redirect-hook needs to be the last one.
            Otherwise the formItAutoResponder - hook doesn't get processed.
              -------------------------------

              you can buy me a beer, if you like MIGX

              http://webcmsolutions.de/migx.html

              Thanks!