Repository navigation
Reset the captcha after AJAX submissions, public JS events, log failed verifications (1.24.0) - #67
Merged
Conversation
…d verifications - A token can be verified only once, so forms that submit without a page reload now reset the widget after each response. Hooks the submission events of CF7, WPForms, Fluent Forms, Formidable, Ninja Forms, JetFormBuilder, User Registration and WooCommerce classic checkout; the AJAX action for Elementor Pro, Everest Forms and Beaver Builder; and the form class for the Blocksy newsletter. - The widget listens for prosopo-procaptcha:reset on the document in the capture phase, and resets when the event target contains it, using the widget id returned by procaptcha.render(). - Public prosopo-procaptcha:filled / :cleared events. The legacy _prosopo-procaptcha__filled is still dispatched for existing code. - Log failed verifications (status, reason, error) when WP_DEBUG is on, and add a prosopo/procaptcha/verification_result action with the response. - Bump to 1.24.0. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This was referenced Oct 29, 2026
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
A Procaptcha token can only be verified once: the provider marks it as server-checked and returns
USER_ALREADY_VERIFIEDon a second verify. Forms that submit over AJAX keep the same widget on the page. So after a failed submission (for example, another field was invalid), the next attempt sends a spent token and is rejected.Changes
Reset after AJAX submissions.
ajaxFormsReset.tsdispatchesprosopo-procaptcha:reseton the submitted form after each response:wpcf7submit(native)wpformsAjaxSubmitFailed(on success the form is replaced)fluentform_submission_success/_failedfrmFormErrors(on success the form is replaced)nfFormSubmitResponsejet-form-builder/ajax/on-success/processing-error/on-failuser_registration_frontend_after_ajax_completecheckout_errorajaxComplete, matched on the AJAX action plus form/node idsubscribe-loadingclass removed (no events)Not covered:
Widget reset. Each widget keeps the ID returned by
procaptcha.render()and listens for the reset event ondocument, in the capture phase. It resets when the event target is the document or contains the widget. If the service script is older and has noreset(), it logs a warning.Public JS events.
prosopo-procaptcha:filled(detail{token}) andprosopo-procaptcha:clearedare dispatched on the widget and bubble up.prosopo-procaptcha:resetresets the widget._prosopo-procaptcha__filledis still dispatched for existing code.widgetEvents.ts.Verification logging.
WP_DEBUGis on, failed verifications go to the debug log with the HTTP code,status,reasonanderror. The token and secret are never logged.prosopo/procaptcha/verification_result( bool $verified, array $body )exposesscore,reasonandsessionId.Version bumped to 1.24.0, with a changelog entry.
Testing
tools/check-code-quality.shpasses: ESLint, Prettier, PHPStan, Pest and PHPCS.tscandyarn buildalso pass.ajaxComplete(heartbeat) reset nothing;documentreset all of them.Possible bugs found along the way (not fixed here)
ur-login.jsposts a fixed set of fields that doesn't includeprocaptcha-response. With the "AJAX login" option on, logins with Procaptcha probably always fail.getElementById('hidden').getAttribute('value'). We set.value, not the attribute, and the ID is shared across the whole page.🤖 Generated with Claude Code