We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 26027
    • 145 Posts
    I'm at my wits end trying to understand what's happening so I've come here hoping some kind soul may be able to tell me what I'm doing wrong.

    Briefly, I'm fairly good (not a pro) with eForm but our developer upgraded us to Revo 2.5 and Formit. I've made a few simple changes with Formit but am hard pressed to do anything clever with it.

    My problem: Some hostile visitor has been frequenting my signup form recently and apparentlly gets his jollies by wasting his time entering invalid email addresses. They're all similar to [email protected] or [email protected]. All I'm trying to do is write a custom validator which looks for 'noreply' or 'donotreply' in the email address and, if found, reject the form without an error message.

    I wrote a small PHP routine (snippet) with the guidance of a person here at ModX Forum. It does not reject the form as I thought it should. After struggling with it and suspecting that the snippet is never being called, I wrote a second snippet which simply does a 'return false'. As I suspected that doesn't work either.

    I'm hoping that one of you may see a defect in the coding of the form which would account for this.

    I'm supplying the Formit call verbatim, except for obfuscating the client's name and email addresses.

    Secondly I'm supplying my original snippet which was ignored, and thirdly my desperation snippet which unconditionally returns false. I'll present those first because they're short and then the Formit call.

    Thanks in advance to anyone who tries to help me.

    Regards ... Sam (Gerber)


    <?php

    /* reject email addresses containing noreply, donotreply */
    $email = $value;
    if (strpos($email, 'noreply') !== false || strpos($email, 'donotreply') !== false)
    {
    return false;
    }
    else {
    return true;
    }


    <?php
    /* reject email addresses unconditionally as a test */
    return false;

    The Formit call:

    [[!FormIt?
    &hooks=`hook.checkResubmission,email,FormItAutoResponder,hook.SetResubmission`
    &emailTpl=`join_our_network_report`
    &emailTo=`[email protected]`
    &emailSubject=`Request To Join Our Network Form`
    &customValidators=`filterNoreply`
    &validate=`nospam:blank,name:required,email:email:required:filterNoreply`
    &successMessage=`<style>#joinournetwork{display:none;}</style><h3>THANK YOU!</h3><p>Your information was successfully submitted.</p>`
    &emailFrom=`[email protected]`
    &emailFromName=`Our Company`
    &fiarTpl=`join_our_network_thanks`
    &fiarSubject=`Thank you for signing up to receive emails from Our Company`
    &fiarToField=`email`
    &fiarFrom=`[email protected]`
    &fiarFromName=`Our Company`
    &fiarHtml=`1`
    &fiarReplyTo=`[email protected]`
    &fiarReplyToName=`Our Company`
    &fiarBCC=`[email protected]`
    ]]
    [[!+fi.resubmit:empty=`
    [[!+fi.successMessage]]
    [[!+fi.validation_error_message:notempty=`
    <div style="margin-top: -10px; margin-bottom: -2px; font-family: Verdana, Arial, sans-serif; font-size: 11px" class="errors">
    <p><strong>Some errors were detected:

    [[!+fi.error.name:notempty=`<span style="font-size: 10px">Name is required</span>
    `]]
    [[!+fi.error.email:notempty=`<span style="font-size: 10px">Your email is not a valid email address</span>
    `]]
    <strong></p></div>
    `]]
    <form id="joinournetwork" action="[[~[[*id]]]]#jonbegin" method="post">
    fieldset>
    <input tabindex="-1" style="position: absolute !important;height: 1px; width: 1px;border: 0; padding: 0;overflow:
    hidden;clip: rect(1px, 1px, 1px, 1px);" name="nospam" id="nospam" type="text" value="" autocomplete="off" />
    <p>
    <input name="name" id="name" class="text" type="text" value="
    [[!+fi.name]]" placeholder="Name (Required)"
    onfocus="if (this.defaultValue==this.value) this.value = ''" />
    <span style="font-size: 11px; font-weight:bold">Name
    [[!+fi.error.name]]</span>
    </p>
    <p>
    <input name="company" id="company" class="text" type="text" value="[[!+fi.company]]" placeholder="Your Organization" onfocus="if (this.defaultValue==this.value) this.value = ''" /> <span style="font-size: 11px; font-weight:bold">Org.[[!+fi.error.company]]</span>
    </p>
    <p>
    <input name="email" id="email" class="text" type="text" value="[[!+fi.email]]" placeholder="Email (Required)"
    onfocus="if (this.defaultValue==this.value) this.value = ''" />
    <span style="font-size: 11px; font-weight:bold">Email[[!+fi.error.email]]</span>
    </p>
    <p>
    <input type="submit" name="join" id="cfJoin" class="button" value="Submit" />
    </p>
    </fieldset>
    </form>
    `]]

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

      • 44969
      • 16 Posts
      I had a similar problem today and fixed it by upgrading to the latest version. See https://forums.modx.com/thread/101358/some-snippets-suddenly-ignored-don-t-know-why
        • 44969
        • 16 Posts
        The version you are currently running, 2.5.0, is confirmed by me to have this problem of certain snippets being ignored. 2.5.2 fixes it, whatever the origin is.
          • 3749
          • 24,544 Posts
          Please don't double post.

          [Sorry, this message was a mistake.] [ed. note: BobRay last edited this post 9 years, 9 months ago.]
            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
            • 26027
            • 145 Posts
            Quote from: BobRay at Dec 01, 2016, 11:34 PM
            Please don't double post.

            BobRay, what are you referring to? "SeriouslyThough"'s remarks are somewhat different comments and take up extremely little space. Why are you criticizing him and possibly embarrassing him publicly? That's not going to help me get my problem solved if you make him go away.

            Wouldn't using PM have done the trick?

            --- Sam
            • discuss.answer
              • 26027
              • 145 Posts
              Quote from: seriouslythough at Dec 01, 2016, 08:33 PM
              The version you are currently running, 2.5.0, is confirmed by me to have this problem of certain snippets being ignored. 2.5.2 fixes it, whatever the origin is.
              I appreciate your feedback but I don't think it can help me. Turns out I'm using ModX 2.5.1-pl which you've indicated doesn't have the problem of ignoring snippets.

              I don't know if the Formit version comes into play but all I can tell is that it's copyrighted 2009-2012 by the author Shaun McCormick.

              I don't have the smarts (experience) to upgrade ModX to 2.52 and there's no guarantee that it's any better than 2.51 since that version doesn't cause you trouble.

              Guess I'll have to keep my fingers crossed that someone else here may be able to help me. Do you know Formit well enough to look at my Formit call to see if anything looks amiss?

              Thanks ... Sam
                • 3749
                • 24,544 Posts
                Quote from: samg at Dec 02, 2016, 10:11 AM
                Quote from: BobRay at Dec 01, 2016, 11:34 PM
                Please don't double post.
                BobRay, what are you referring to?

                My Bad

                @samg - Sorry, my comment was a mistake. It was aimed at you, not SeriouslyThough. My excuse is complicated, but in short, due to a trivial bug in the Forum software, it appeared to me that you had posted your original message multiple times.

                Sorry for the confusion.

                  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