We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 19328
    • 433 Posts
    I'm using Quip 2.3.1 on MODX Revo 2.2.2 (with Articles) and I was trying to implement a simple anti-spam solution (because I find the recaptcha not really user friendly, especially for elderly visitors of the site).

    I would like to do one of the following (or both):
    - add an extra input field that has to stay empty and hide it with css.
    - add a simple math question (like '2 + 3 = ?') and make the field have to be '5'.

    I can't really find a way to do this though. Would it be possible? The extra fields don't have to be stored, displayed or emailed, but they do have to be validated before a comment will be approved.

    Can anyone point me in the right direction where I could add this functionality? Thanks for any help!
      • 3749
      • 24,544 Posts
      I'm not sure how difficult it would be to integrate with Quip, but the MODX Captcha package has the mathstring option and can be called independently (see the SPForm code).

      You would need a custom validator in Quip that checked the user's input against the $_SESSION variable set by Captcha. I'm not sure if that's possible or not.


      ------------------------------------------------------------------------------------------
      PLEASE, PLEASE specify the version of MODX you are using.
      MODX info for everyone: http://bobsguides.com/modx.html
        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
        • 19328
        • 433 Posts
        Thanks Bob, I think I found something. I discovered it's possible to add pre- and postHooks to the Quip snippet call. And in quiphooks.class.php I found a math hook. Exactly what I'm looking for!
        Just can't find any examples on how to implement it, so I'm trying on my own now. I'll post back if I get it working.
          • 19328
          • 433 Posts
          Alright, I got the math hook working. Had to alter a core file though. This is what I've done:

          1) in core/components/articles/model/articles/article.class.php I added the hook to the QuipReply snippet call. Don't know if I should be doing it this way but for now it works.
          Find the getCommentsReplyCall function around line 137 and add:
          &preHooks=`math` 

          to the snippet call (I added it below all the other parameters).

          2) make sure your quipAddComment chunk (I made a custom chunk for this) has fields with the names
          - op1 (first nr), op2 (second nr), operator (+, - or *) and math (user has to fill in the answer to the question here).

          3) Now it should be working but didn't so I googled around and found this Czech forum post:
          http://www.modxcms.cz/forums/tema-v-novem-quip-nefunguji-prehooks

          Using Google Translate I figured there was a small bug in a Quip file.
          So I opened core/components/quip/processors/web/comment/create.php
          and changed

          $quip->preHooks->loadMultiple($this->getProperty('preHooks',''),$this->getProperties(),array(


          into
          $quip->preHooks->loadMultiple($this->getProperty('preHooks',''),$fields,array(
          

          (around line 90).

          And it works!
            • 3749
            • 24,544 Posts
            The first method you tried would be the correct way, but if there's a bug in Quip, your method might be the only way.


            ------------------------------------------------------------------------------------------
            PLEASE, PLEASE specify the version of MODX you are using.
            MODX info for everyone: http://bobsguides.com/modx.html
              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
              • 44854
              • 21 Posts
              Hi I have tried and changed files exactly same as per your instructions but it is not working for me sad

              Quote from: michelle84 at May 18, 2012, 08:35 AM
              Alright, I got the math hook working. Had to alter a core file though. This is what I've done:

              1) in core/components/articles/model/articles/article.class.php I added the hook to the QuipReply snippet call. Don't know if I should be doing it this way but for now it works.
              Find the getCommentsReplyCall function around line 137 and add:
              &preHooks=`math` 

              to the snippet call (I added it below all the other parameters).

              2) make sure your quipAddComment chunk (I made a custom chunk for this) has fields with the names
              - op1 (first nr), op2 (second nr), operator (+, - or *) and math (user has to fill in the answer to the question here).

              3) Now it should be working but didn't so I googled around and found this Czech forum post:
              http://www.modxcms.cz/forums/tema-v-novem-quip-nefunguji-prehooks

              Using Google Translate I figured there was a small bug in a Quip file.
              So I opened core/components/quip/processors/web/comment/create.php
              and changed

              $quip->preHooks->loadMultiple($this->getProperty('preHooks',''),$this->getProperties(),array(


              into
              $quip->preHooks->loadMultiple($this->getProperty('preHooks',''),$fields,array(
              

              (around line 90).

              And it works!
                • 19328
                • 433 Posts
                Quote from: hitesh571985 at Mar 21, 2014, 12:11 PM
                Hi I have tried and changed files exactly same as per your instructions but it is not working for me sad

                You should really provide some more information. It can be everything right now wink

                You PM'ed me with the request to post my custom quipAddComment chunk. Here it is. Although there are some Dutch words in it, it should be understandable.
                [[+preview:notempty=`<h2>Een voorbeeld van uw bericht:</h2>[[+preview]]` ]]
                [[+successMsg:notempty=`<span class="quip-success" id="quip-success-[[+idprefix]]">[[+successMsg]]</span>`]]
                
                [[+error:notempty=`
                <div class="errorSummary">
                <h3>Er zijn fouten gevonden in het formulier</h3>
                <ul>
                [[+error.name:notempty=`<li>Het veld <a href="[[~[[*id]]]]#quip-comment-name-[[!+idprefix]]">'naam'</a> is niet ingevuld</li>`]]
                [[+error.email:notempty=`<li>Het veld <a href="[[~[[*id]]]]#quip-comment-email-[[!+idprefix]]">'e-mail'</a> is niet ingevuld</li>`]]
                [[+error.comment:notempty=`<li>Het veld <a href="[[~[[*id]]]]#quip-comment-box-[[!+idprefix]]">'reactie'</a> is niet ingevuld</li>`]]
                [[+error.math:notempty=`<li>De <a href="[[~[[*id]]]]#quip-comment-math-[[!+idprefix]]">anti-spamvraag</a> is niet goed ingevuld</li>`]]
                </ul>
                </div>
                `]]
                
                <form class="formulier commentform" id="quip-add-comment-[[+idprefix]]" action="[[+url]]#quip-comment-preview-box-[[+idprefix]]" method="post">
                <div class="quip-comment quip-add-comment" id="quip-comment-preview-box-qcom">
                    <input type="hidden" name="nospam" value="" />
                    <input type="hidden" name="thread" value="[[+thread]]" />
                    <input type="hidden" name="parent" value="[[+parent]]" />
                    <input type="hidden" name="auth_nonce" value="[[+auth_nonce]]" />
                    <input type="hidden" name="preview_mode" value="[[+preview_mode]]" />
                
                     <div class="quip-fld">
                        <label for="quip-comment-name-[[+idprefix]]" [[+error.name:notempty=`class="errorFirstLabel"`]]>[[%quip.name? &namespace=`quip` &topic=`default`]]*</label>
                        <input type="text" class="required [[+error.name:notempty=`error`]]" name="name" id="quip-comment-name-[[+idprefix]]" value="[[+name]]" />
                	  [[+error.name:notempty=`<span class="quip-error">[[+error.name]]</span>`]]
                    </div>
                    
                    <div class="quip-fld">
                        <label [[+error.email:notempty=`class="errorFirstLabel"`]] for="quip-comment-email-[[+idprefix]]">[[%quip.email]]*<span class="note">Je e-mailadres wordt niet gepubliceerd.</span></label>
                      <input type="text" class="required email [[+error.email:notempty=`error`]]" name="email" id="quip-comment-email-[[+idprefix]]" value="[[+email]]" />[[+error.email:notempty=`<span class="quip-error">[[+error.email]]</span>`]]
                    </div>
                    
                    <div class="quip-fld">
                        <label for="quip-comment-website-[[+idprefix]]">[[%quip.website]]<span class="quip-error">[[+error.website]]</span></label>
                        <input type="text" name="website" class="url" id="quip-comment-website-[[+idprefix]]" value="[[+website]]" />
                    </div>
                
                       <label [[+error.comment:notempty=`class="errorFirstLabel"`]] class="labelTextarea" for="quip-comment-box-[[+idprefix]]">Je bericht</label>
                    <textarea class="required [[+error.comment:notempty=`error`]]" name="comment" id="quip-comment-box-[[+idprefix]]" rows="5" cols="70">[[+comment]]</textarea>
                    <p>
                      [[+error.comment:notempty=`<span class="quip-error">[[+error.comment]]</span>`]]
                      </p>
                    
                
                <div class="quip-fld antispam">
                      <label [[+error.math:notempty=`class="errorFirstLabel"`]] for="quip-comment-math-[[+idprefix]]">Hoeveel is 3 + 2?</label> 
                      <input type="hidden" id="op1" name="op1" value="3" /> <input type="hidden" id="operator" name="operator" value="+" /> <input type="hidden" id="op2" name="op2" value="2" /> 
                      <input type="text" class="[[+error.math:notempty=`error`]] math" name="math" id="quip-comment-math-[[+idprefix]]" value="[[+math]]" />
                
                      [[+error.math:notempty=`<span class="quip-error">Vul hier '5' in.</span>`]]
                      </div> 
                
                
                      <div class="quip-fld checkbox">
                        [[+unsubscribe:default=`
                        <input class="inputCheckbox" type="checkbox" value="1" name="notify" id="quip-comment-notify-[[+idprefix]]" [[+notifyChecked]] />
                        `]]
                      <label class="labelCheckbox" for="quip-comment-notify-[[+idprefix]]">[[%quip.notify_me]]<span class="quip-error">[[+error.notify]]</span></label>
                        
                    </div>
                
                       [[+can_post:is=`1`:then=`<button type="submit" class="actieButton" name="[[+post_action]]" value="1">[[%quip.post]]</button>`]]
                    
                </div>
                </form>
                
                


                  • 31104
                  • 108 Posts
                  Wow thank you kindly Michelle, this is a great alternative to recaptcha, which besides being complicated, does not resize for mobiles and really breaks any mobile site that is less than 600px wide.
                    • 3749
                    • 24,544 Posts
                    In my experience, the math option if the most reliable spam filter going, at least the version in SPForm, which makes the math string an image -- not sure if your version does that, but that capability is built into the Captcha plugin.
                      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
                      • 52149
                      • 11 Posts
                      @michelle84 The math captcha code works if the field is left empty but if wrong answer is given and submitted then it doesn't show the comment form. How to make the math numbers random on each submit?