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

    Im trying to make a custom hook to block spam links. I looked at the FormIt documentation but the snippet hook isn’t working. I’m not that familiair
    with the syntax of MODx. So i basicaly started with trial and error.

    But after a lot of go’s it still aint working. So I went to the forum, I hope someone here can help me out.

    This is the snippet code where i’m working on:
    <?php
    $allFormFields = $hook->getValues();
      
    if(preg_match('/(href=|\[url\]|\[url=|\[link=)/', $allFormFields))
    {
       $errorMsg = 'Forbidden to send links.';  
       $hook->addError('LinkSpam',$errorMsg);  
       return false;
    }
    else
    {
       return true;
    }
    
    
    • Hard to tell just from that. Can you include the Formit Snippet call as well?
        Kelsey
        • 13935
        • 16 Posts
        Hi,

        This is my complete snippet call:

        [[!FormIt?
         &emailSubject=`Form Subject!`  
         &hooks=`spam,email,LinkSpam,redirect`  
         &redirectTo=`22`
         &emailTpl=`EmailForm`  
         &submitVar=`verzenden`
         &store=`1`
         &emailTo=`[email protected]`    
         &validate=`naam:required,  
              email:email,
              onderwerp:required`        
        ]]
        


        I hope you can help me.