We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 45090
    • 10 Posts
    MODx Revo: 2.0.8-pl
    quip: 1.2.5

    I have a guestbook with 2 text fields (name and message) and a submit button using quip. I've added reCaptcha.
    When one of the text fields is not filled (along with reCaptcha) it gives validation error that reCaptcha is not set correctly (expectedly). However when both text fields are filled, it doesn't check the reCaptcha and submits.

    What can be causing reCaptcha not being checked when all fields are filled?

    Thanks.

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

      • 45090
      • 10 Posts
      It seems that reCaptcha's validation is outside scope of validation for other fields. If other fields OK, it submits and doesn't check whether reCaptcha was entered or matched. I can't find where these validation is done though. Would appreciate any hint.

      Thanks.
        • 3749
        • 24,544 Posts
        Did you add &hooks=`recaptcha` to the FormIt tag?

        BTW, you really should update MODX. There are some important security fixes in later versions.
          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
          • 45090
          • 10 Posts
          Thanks for the tip BobRay, I think we'll update to the latest version soon.

          No I didn't add hook, since it wasn't using FormIt but Quip. Should I add a hook?
          I'll add the call below, but I think the problem is with validation. reCaptcha shows properly and validates as long as not both other fields are filled and on submit gives error that reCaptcha does not pass. But when both field are filled, it ignores reCaptcha and submits. I couldn't find where quip does the validation though.

          [[!QuipReply? &closeAfter=`0` &thread=`Guestbook` &tplAddComment=`guestbookAddComment` 
          &tplPreview=`guestbookPreview` &dateFormat=`%Y-%m-%d %H:%M` &autoConvertLinks=`0` &recaptcha=`1` &disableRecaptchaWhenLoggedIn=`0`]]
            • 3749
            • 24,544 Posts
            In the case of QuipReply, I think it's &recaptcha=`1` though by default, recaptcha is ignored if you're logged in. You might need &hooks='recaptcha' as well, since QuipReply does have hooks, but I don't think you'll need it.

            &disableRecaptchaWhenLoggedIn=`0 should make it require reCaptcha whether you're logged in or not.
              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
              • 45090
              • 10 Posts
              If &disableRecaptchaWhenLoggedIn is not set or set to 1, reCaptcha won't show whether logged in or not. I tried with &hooks=`recaptcha` with the same result.
                • 3749
                • 24,544 Posts
                Are you viewing from a separate browser where you aren't logged in to the Manager?

                  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
                  • 45090
                  • 10 Posts
                  Don't think if I tried different browser. Both in Chrome, logged in in a normal window and regular user in an incognito window (which wasn't logged in of course) both with the same behavior. I picked up the thing about adding &disableRecaptchaWhenLoggedIn=`0` from here: https://forums.modx.com/index.php?topic=59351.0
                  it wasn't showing at all neither manager or normal user untill I added that and it only worked with the value 0 (similar to what happened in that thread.

                  But I don't think it has anything to do with being logged in or not, since it checks reCaptcha. Just the way it checks is weird as when other fields have value it ignores it, but when one or both fields are empty it throws a warning about reCaptcha not matching (when it's empty or wrong).

                  Anyway I gave up on reCaptcha, Tried Captcha extra, but it lacked documentation (or examples) and I wasn't sure how to use it for forms. So I wrote a simple match captcha and added it to the form.

                  Thanks again.
                  • discuss.answer
                    • 3749
                    • 24,544 Posts
                    Did you see this: http://bobsguides.com/captcha-plugin.html? It could use more detail and examples, but it does explain how to use it in a form.
                      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
                      • 45090
                      • 10 Posts
                      Thanks BobRay.

                      That one line of code you provided in your guide - however primitive it might sound - was the missing link and made whole lotta difference for me. I tried including that php file along with some other failed attempts. (oh well)

                      Don't know if something has changed, I did something wrong or assets_path needed to be set first, but had to change
                      <img src="[[++assets_path]]components/captcha/captcha.php" alt="Captcha Image" />
                      
                      to
                      <img src="./assets/components/captcha/captcha.php" alt="Captcha Image" />
                      
                      to get the image load. And maybe I had to do something about cache, but the image seems to be - most of the time - one step behind the value (the next image matches the current 'veriword' value.

                      Here's what I do:
                      <img src="./assets/components/captcha/captcha.php" alt="Captcha Image" />
                        <input id="my_textcha" type="text" />
                        <div id="mytst">[[!samtcha]]</div>


                      And samtcha only echoes
                      <?php echo $_SESSION['veriword'];