Title: shock81's Replies | WordPress.org

---

# shock81

  [  ](https://wordpress.org/support/users/shock81/)

 *   [Profile](https://wordpress.org/support/users/shock81/)
 *   [Topics Started](https://wordpress.org/support/users/shock81/topics/)
 *   [Replies Created](https://wordpress.org/support/users/shock81/replies/)
 *   [Reviews Written](https://wordpress.org/support/users/shock81/reviews/)
 *   [Topics Replied To](https://wordpress.org/support/users/shock81/replied-to/)
 *   [Engagements](https://wordpress.org/support/users/shock81/engagements/)
 *   [Favorites](https://wordpress.org/support/users/shock81/favorites/)

 Search replies:

## Forum Replies Created

Viewing 7 replies - 1 through 7 (of 7 total)

 *   Forum: [Plugins](https://wordpress.org/support/forum/plugins-and-hacks/)
    In
   reply to: [[Contact Form 7] Where is wpcf7submit event (recaptcha/script.js) is executed or created?](https://wordpress.org/support/topic/where-is-wpcf7submit-event-recaptcha-script-js-is-executed-or-created/)
 *  Thread Starter [shock81](https://wordpress.org/support/users/shock81/)
 * (@shock81)
 * [5 years, 7 months ago](https://wordpress.org/support/topic/where-is-wpcf7submit-event-recaptcha-script-js-is-executed-or-created/#post-13542060)
 * Yes that’s what I saw yesterday. The current implementation makes it hard to 
   listen on submit and run the code before submit that’s why I placed my code on
   hover and on active, to make sure it is run before click and though before submit.
   The problem is getting the response and manipulating the DOM to add the token
   takes time (ms) and so there’s no guarantee to make sure the token is refreshed
   before submit.
 * For me, the perfect solution would be to be able to add a listener on submit 
   event – document.addEventListener( ‘wpcf7submit’) – and run this code before 
   the ajax call. Another solution, would be to edit your scripts.js file but I 
   wanted to keep unedited.
    -  This reply was modified 5 years, 7 months ago by [shock81](https://wordpress.org/support/users/shock81/).
 *   Forum: [Plugins](https://wordpress.org/support/forum/plugins-and-hacks/)
    In
   reply to: [[Contact Form 7] Where is wpcf7submit event (recaptcha/script.js) is executed or created?](https://wordpress.org/support/topic/where-is-wpcf7submit-event-recaptcha-script-js-is-executed-or-created/)
 *  Thread Starter [shock81](https://wordpress.org/support/users/shock81/)
 * (@shock81)
 * [5 years, 8 months ago](https://wordpress.org/support/topic/where-is-wpcf7submit-event-recaptcha-script-js-is-executed-or-created/#post-13540635)
 * Hi again,
 * by now I’ve coded this [1] in order to be able to generate new recaptcha tokens
   on hover or focus “in” on the submit button.
 * It’s not the perfect solution but may help. What I would really like is to be
   able to “externally” – so do it from the JS I’ve coded – be able to (1)pause/
   stop the form submition, (2)generate a new captcha token and (3) resume the form
   submition or submit.
 * Looking at scripts-v5.2.2.js I see 2 points of interest, (1) wpcf7.initForm:50(
   $form.submit) and wpcf7.submit:158. I’m trying to capture those events when triggered
   so I can run my code before the submition of the form but I’m not able to. If
   you could give me some tips on how or which events do I need to add the jQuery
   EventListener functions I would be much appreciated. 🙂
 * The problem I’m having when adding listeners to submit is my code runs after 
   or while submit so I’m not 100% sure the token is going to be generated before
   submit. I hope you can clarify or give some light to it.
 * Thanks a lot! 🙂
 * [1] [https://gist.github.com/pauperis/658453e28b15744b6c0ad42ca503d3d0](https://gist.github.com/pauperis/658453e28b15744b6c0ad42ca503d3d0)
 *   Forum: [Plugins](https://wordpress.org/support/forum/plugins-and-hacks/)
    In
   reply to: [[Contact Form 7] Where is wpcf7submit event (recaptcha/script.js) is executed or created?](https://wordpress.org/support/topic/where-is-wpcf7submit-event-recaptcha-script-js-is-executed-or-created/)
 *  Thread Starter [shock81](https://wordpress.org/support/users/shock81/)
 * (@shock81)
 * [5 years, 8 months ago](https://wordpress.org/support/topic/where-is-wpcf7submit-event-recaptcha-script-js-is-executed-or-created/#post-13537341)
 * Hello, again and thanks a lot for your comments! 🙂
 * What’s wrong, in your opinion, on refreshing Google Recaptcha Token on “pre” 
   submit, I mean when the user clicks on submit? To me, it looks like a valid solution.
 * Another possibility is to generate new tokens when the user hovers the submit
   button but only if the form is fully filled, to not generate unnecessary requests.
 * Thank u very much for your time. 🙂
    -  This reply was modified 5 years, 8 months ago by [shock81](https://wordpress.org/support/users/shock81/).
 *   Forum: [Plugins](https://wordpress.org/support/forum/plugins-and-hacks/)
    In
   reply to: [[Contact Form 7] Where is wpcf7submit event (recaptcha/script.js) is executed or created?](https://wordpress.org/support/topic/where-is-wpcf7submit-event-recaptcha-script-js-is-executed-or-created/)
 *  Thread Starter [shock81](https://wordpress.org/support/users/shock81/)
 * (@shock81)
 * [5 years, 8 months ago](https://wordpress.org/support/topic/where-is-wpcf7submit-event-recaptcha-script-js-is-executed-or-created/#post-13534312)
 * When talking about cached pages should I understand a user accessing the web 
   page through Google cached site? I mean, when a web browser loads a web page 
   JS gets executed in the browser so the token should change. Also, AFAIK, the 
   token is only valid for 2-3 minutes. Would you mind to tell me what do I exactly
   should understand by the web page being cached? web sites served through memcached?
 * Also, your implementation of of recaptcha takes into account the use case where
   a user takes more than 3 minutes to fill a contact form? I mean, imagine a user
   who is writing a description or message field, it takes him 8 minutes so the 
   token would not be valid.
 * If I’m not mistaken, submit event does not generate a new token and maybe it 
   would be a good idea in order to solve the previous use case where a user takes
   more than 3 minutes to fulfill and send the form. What do you think about it?
 * Thanks! 🙂
 *   Forum: [Plugins](https://wordpress.org/support/forum/plugins-and-hacks/)
    In
   reply to: [[Contact Form 7] Where is wpcf7submit event (recaptcha/script.js) is executed or created?](https://wordpress.org/support/topic/where-is-wpcf7submit-event-recaptcha-script-js-is-executed-or-created/)
 *  Thread Starter [shock81](https://wordpress.org/support/users/shock81/)
 * (@shock81)
 * [5 years, 8 months ago](https://wordpress.org/support/topic/where-is-wpcf7submit-event-recaptcha-script-js-is-executed-or-created/#post-13532541)
 * Thanks a lot for your support.
 * If I may, one last question, how caching is supposed to work? I’m not sure I 
   understand the caching concept here.
 * Thank u so much 🙂
 *   Forum: [Plugins](https://wordpress.org/support/forum/plugins-and-hacks/)
    In
   reply to: [[Contact Form 7] Where is wpcf7submit event (recaptcha/script.js) is executed or created?](https://wordpress.org/support/topic/where-is-wpcf7submit-event-recaptcha-script-js-is-executed-or-created/)
 *  Thread Starter [shock81](https://wordpress.org/support/users/shock81/)
 * (@shock81)
 * [5 years, 8 months ago](https://wordpress.org/support/topic/where-is-wpcf7submit-event-recaptcha-script-js-is-executed-or-created/#post-13529720)
 * Hi, again! 🙂
 * I’ve been reading recaptcha/script.js, contact-form-7/includes/js/scripts.js 
   as well as some other PHP files included in the plugin .zip.
 * The thing is I’ve coded some PHP classes to handle a custom form validation and
   mail submission to work together with contact-form-7/includes/js/scripts.js for
   my dad’s web page and it’s doing great.
 * Now, I’m giving a look at recaptcha/script.js as well as recaptcha.php just to
   understand the logic behind your recaptcha implementation. I’ve noticed there’s
   a /refill request in scripts.js.
 * If you don’t mind, I would like to ask:
    * Recaptcha token validation against
   Google servers, is done only on form submition or also via ajax while the user
   keeps filling in the form fields? I’ve noticed a new token is generated each 
   time a user changes the active input form field. * Could you tell me what’s the
   exact job of the refill (scripts.js) function? * The quiz function in the refill(
   scripts.js) function is for backward compatibility with recaptcha v2? AFAIK there’s
   no way to rebound users to recaptcha v2 once recaptcha v3 scores them as bot,
   isn’t it?
 * Thanks a lot for your time,
    -  This reply was modified 5 years, 8 months ago by [shock81](https://wordpress.org/support/users/shock81/).
 *   Forum: [Plugins](https://wordpress.org/support/forum/plugins-and-hacks/)
    In
   reply to: [[Contact Form 7] Where is wpcf7submit event (recaptcha/script.js) is executed or created?](https://wordpress.org/support/topic/where-is-wpcf7submit-event-recaptcha-script-js-is-executed-or-created/)
 *  Thread Starter [shock81](https://wordpress.org/support/users/shock81/)
 * (@shock81)
 * [5 years, 8 months ago](https://wordpress.org/support/topic/where-is-wpcf7submit-event-recaptcha-script-js-is-executed-or-created/#post-13527435)
 * Thanks a lot for the fast reply. I saw it minutes after you posted the answer
   and it was of great help. 🙂

Viewing 7 replies - 1 through 7 (of 7 total)