<![CDATA[ [SOLVED] reCaptcha V2 no longer works on multiple sites after MODx 2.6.5 upgrade - My Forums]]> https://forums.modx.com/thread/?thread=104294 <![CDATA[ [SOLVED] reCaptcha V2 no longer works on multiple sites after MODx 2.6.5 upgrade]]> https://forums.modx.com/thread/104294/recaptcha-v2-no-longer-works-on-multiple-sites-after-modx-2-6-5-upgrade#dis-post-560947
Although the submissions DOES go through, the error message fools the site visitor into attempting the form again, resulting in multiple submissions.

The error log within the manager is filled with these submissions:

[2018-08-20 15:17:16] (ERROR @ /home/username/public_html/core/components/formit/src/FormIt/Request.php : 87) [FormIt] Could not load FormItReCaptcha service class.
[2018-08-20 15:17:20] (ERROR @ /home/username/public_html/core/components/formit/src/FormIt/Request.php : 87) [FormIt] Could not load FormItReCaptcha service class.
[2018-08-20 15:17:20] (ERROR @ /home/username/public_html/core/components/formit/src/FormIt/Request.php : 87) [FormIt] Could not load FormItReCaptcha service class.
[2018-08-20 15:17:31] (ERROR @ /home/username/public_html/core/components/formit/src/FormIt/Request.php : 87) [FormIt] Could not load FormItReCaptcha service class.


1. I made sure I had the correct reCaptcha keys were set.
2. I removed ReCaptchaV2 package completely and reinstalled. No good.
3. Core/cache cleared.
4. Reverted Formit back to the previous version (version 2.2.7-px) but that ended up crashing the entire front of the site...500 error. Luckily, the manager still worked since I was able to install the latest version of Formit back (version 4.1.0-pl), bringing the site back, but still not correcting the reCaptcha problem. BTW: after the crash, I saw this in the manager error log:

[2018-08-20 15:15:03] (ERROR @ /home/username/public_html/core/xpdo/xpdo.class.php : 644) Could not load class: FormIt from formit.
[2018-08-20 15:15:08] (ERROR @ /home/username/public_html/core/xpdo/xpdo.class.php : 644) Could not load class: FormIt from formit.
[2018-08-20 15:15:15] (ERROR @ /home/username/public_html/core/xpdo/xpdo.class.php : 644) Could not load class: FormIt from formit.
[2018-08-20 15:15:20] (ERROR @ /home/username/public_html/core/xpdo/xpdo.class.php : 644) Could not load class: FormIt from formit.
[2018-08-20 15:15:24] (ERROR @ /home/username/public_html/core/xpdo/xpdo.class.php : 644) Could not load class: FormIt from formit.
[2018-08-20 15:16:08] (ERROR @ /home/username/public_html/core/xpdo/xpdo.class.php : 644) Could not load class: FormIt from formit.
[2018-08-20 15:16:18] (ERROR @ /home/username/public_html/core/xpdo/xpdo.class.php : 644) Could not load class: FormIt from formit.
[2018-08-20 15:16:29] (ERROR @ /home/username/public_html/core/xpdo/xpdo.class.php : 644) Could not load class: FormIt from formit.


My form code, which was working before my upgrade(s), is this:

[[!FormIt?  
&hooks=`recaptchav2,spam,FormSave,email,emailUser-contact,redirect`
&submitVar=`contact_page`
&emailSubject=`Submission Through The Whatever Contact Page`
&emailTpl=`contact_page_EmailChunk`
&emailTo=`[email protected],[email protected]`
&emailFrom=`[[+email-contact]]`
&redirectTo=`10`
&fsFormTopic=`Contact Page`
&fsFormFields=`firstName-contact,lastName-contact,telephone-contact,email-contact,subject-contact,text-contact`
]]

[[!+fi.error.error_message:notempty=`
<p>[[!+fi.error.error_message]]</p>
`]]





<div class="col-md-12">
                            <form class="form" action="[[~[[*id]]]]" method="post" id="contactForm" >
								<div class="row">
									<div class="form-group">
										<div class="col-md-6">
											<label for="firstName-contact">First Name *
                                            <span class="error">[[+fi.error.firstName-contact]]</span></label>
											<input type="text" value="[[+fi.firstName-contact]]" maxlength="100" class="form-control" name="firstName-contact" id="firstName-contact" required>
                                            <input name="nospam:blank" type="hidden" />
										</div>
										<div class="col-md-6">
											<label for="lastName-contact">Last Name *<span class="error">[[+fi.error.lastName-contact]]</span></label>
											<input type="text" value="[[+fi.lastName-contact]]" maxlength="100" class="form-control" name="lastName-contact" id="lastName-contact" required>
										</div>
									</div>
								</div>
                                
								<div class="row">
									<div class="form-group">
										<div class="col-md-6">
											<label for="email-contact">Email *
                                            <span class="error">[[+fi.error.email-contact]]</span></label>
											<input type="text" value="[[+fi.email-contact]]" maxlength="100" class="form-control" name="email-contact" id="email-contact" required>
										</div>
										<div class="col-md-6">
											<label for="telephone-contact">Telephone *<span class="error">[[+fi.error.telephone-contact]]</span></label>
											<input type="text" value="[[+fi.telephone-contact]]" maxlength="100" class="form-control" name="telephone-contact" id="telephone-contact" required>
										</div>
									</div>
								</div>

                                
								<div class="row">
									<div class="form-group">
										<div class="col-md-12">
											<label for="subject-contact">Subject</label>
											<input type="text" value="[[+fi.subject-contact]]" maxlength="100" class="form-control" name="subject-contact" id="subject-contact">
										</div>
									</div>
								</div>
								<div class="row">
									<div class="form-group">
										<div class="col-md-12">
											<label for="text-contact">Message</label>
											<textarea maxlength="5000" rows="10" class="form-control" name="text-contact" id="text-contact">[[+fi.text-contact]]</textarea>
										</div>
									</div>
								</div>
								<div class="row">
									<div class="form-group">
										<div class="col-md-12">
 											
[[!recaptchav2_render]]<span style="color: #ff0000; font-size: 1.2em; font-weight: bold;">[[!+fi.error.recaptchav2_error]]</span>

										</div>
									</div>
								</div>
								<div class="row">
									<div class="col-md-12">
                                                                                <input type="hidden" name="subject" id="subject" value="Submission Through The Whatever Website Contact Page" />
										<input type="submit" value="Submit" class="btn btn-primary btn-lg" name="contact_page" >
									</div>
								</div>
							</form>
						</div>
<div style="clear: both;"></div>


This same issue is happening on several sites. Any thoughts would be appreciated.

MODx 2.6.5
PHP 7.0
FormIt 4.1.0-pl
ReCaptchaV2 2.3.0-rc1]]>
waizen Aug 20, 2018, 07:42 PM https://forums.modx.com/thread/104294/recaptcha-v2-no-longer-works-on-multiple-sites-after-modx-2-6-5-upgrade#dis-post-560947
<![CDATA[Re: reCaptcha V2 no longer works on multiple sites after MODx 2.6.5 upgrade (Best Answer)]]> https://forums.modx.com/thread/104294/recaptcha-v2-no-longer-works-on-multiple-sites-after-modx-2-6-5-upgrade#dis-post-561260
Again, using the error message to find any more solutions online, I came across this page (translated):

https://github.com/Sterc/FormIt/issues/170&xid=25657,15700019,15700124,15700149,15700186,15700191,15700201&usg=ALkJrhgbXX4vIBd6gAJrFcw8-6NuGT1NdQ" target="_blank" rel="nofollow">https://translate.googleusercontent.com/translate_c?depth=1&hl=en&prev=search&rurl=translate.google.com&sl=ru&sp=nmt4&u=https://github.com/Sterc/FormIt/issues/170&xid=25657,15700019,15700124,15700149,15700186,15700191,15700201&usg=ALkJrhgbXX4vIBd6gAJrFcw8-6NuGT1NdQ

I utilized the solution offered by Andres-M-Rios on that page. At that point, my original repeating error:

[2018-08-20 15:17:31] (ERROR @ /home/username/public_html/core/components/formit/src/FormIt/Request.php : 87) [FormIt] Could not load FormItReCaptcha service class.


...in the MODx manager went away but replaced with another one:

[2018-08-30 13:44:46] (ERROR @ /home/username/public_html/core/cache/includes/elements/modsnippet/20.include.cache.php : 29) An error occurred while trying to send the email: 


Looking inside that cache file, I recognized the contents as the template I created a long time ago as a thank you message to the form visitor. So, as a hunch, I took out the "emailUser-contact" entry from the &hooks=`recaptchav2,spam,FormSave,email,emailUser-contact,redirect` hook chain.

That apparently fixed it. I'll monitor this for for a few days to make sure the fix has taken before employing it on the other sites I'm having the same issue with. Thank you, Bob, for all your help. I's been greatly appreciated!]]>
waizen Aug 30, 2018, 08:06 PM https://forums.modx.com/thread/104294/recaptcha-v2-no-longer-works-on-multiple-sites-after-modx-2-6-5-upgrade#dis-post-561260
<![CDATA[Re: reCaptcha V2 no longer works on multiple sites after MODx 2.6.5 upgrade]]> https://forums.modx.com/thread/104294/recaptcha-v2-no-longer-works-on-multiple-sites-after-modx-2-6-5-upgrade#dis-post-561248
Are there any other good captcha solutions out there? I know that there is this:

https://modx.com/extras/package/captcha 


...but that is apparently for the login page form. Bob, you hint that it can be somehow converted for use in front end forms? Can you provide detailed instructions as to how that can be done?

Other than that, does anyone know of any other captcha systems for MODx?]]>
waizen Aug 30, 2018, 03:16 PM https://forums.modx.com/thread/104294/recaptcha-v2-no-longer-works-on-multiple-sites-after-modx-2-6-5-upgrade#dis-post-561248
<![CDATA[Re: reCaptcha V2 no longer works on multiple sites after MODx 2.6.5 upgrade]]> https://forums.modx.com/thread/104294/recaptcha-v2-no-longer-works-on-multiple-sites-after-modx-2-6-5-upgrade#dis-post-561243 Quote from: BobRay at Aug 27, 2018, 09:03 PM
...You could look to see if the formit.class.php file is at that location.

Yes, it is.]]>
waizen Aug 30, 2018, 02:34 PM https://forums.modx.com/thread/104294/recaptcha-v2-no-longer-works-on-multiple-sites-after-modx-2-6-5-upgrade#dis-post-561243
<![CDATA[Re: reCaptcha V2 no longer works on multiple sites after MODx 2.6.5 upgrade]]> https://forums.modx.com/thread/104294/recaptcha-v2-no-longer-works-on-multiple-sites-after-modx-2-6-5-upgrade#dis-post-561169
$modelPath = $modx->getOption(
    'formit.core_path',
    null,
    $modx->getOption('core_path', null, MODX_CORE_PATH) . 'components/formit/'
) . 'model/formit/';
$modx->loadClass('FormIt', $modelPath, true, true);


and your error message saying that it couldn't find the formit class file.

I was wrong about the property name, though. It would be 'formit.core_path', but it would default to core/components/formit/model/formit/. You could look to see if the formit.class.php file is at that location.]]>
BobRay Aug 27, 2018, 09:03 PM https://forums.modx.com/thread/104294/recaptcha-v2-no-longer-works-on-multiple-sites-after-modx-2-6-5-upgrade#dis-post-561169
<![CDATA[Re: reCaptcha V2 no longer works on multiple sites after MODx 2.6.5 upgrade]]> https://forums.modx.com/thread/104294/recaptcha-v2-no-longer-works-on-multiple-sites-after-modx-2-6-5-upgrade#dis-post-561167

[[!FormIt?  
&hooks=`recaptchav2,spam,FormSave,email,emailUser-contact,redirect`
&submitVar=`contact_page`
&emailSubject=`Submission Through The Whatever Contact Page`
&emailTpl=`contact_page_EmailChunk`
&emailTo=`[email protected],[email protected]`
&emailFrom=`[[+email-contact]]`
&redirectTo=`10`
&fsFormTopic=`Contact Page`
&fsFormFields=`firstName-contact,lastName-contact,telephone-contact,email-contact,subject-contact,text-contact`
]]


Is that where you're referring to? This was after an upgrade to 2.6.5 so nothing should have changed; it was working before.]]>
waizen Aug 27, 2018, 08:02 PM https://forums.modx.com/thread/104294/recaptcha-v2-no-longer-works-on-multiple-sites-after-modx-2-6-5-upgrade#dis-post-561167
<![CDATA[Re: reCaptcha V2 no longer works on multiple sites after MODx 2.6.5 upgrade]]> https://forums.modx.com/thread/104294/recaptcha-v2-no-longer-works-on-multiple-sites-after-modx-2-6-5-upgrade#dis-post-560986
If not, add one with the correct path to the FormIt model directory.]]>
BobRay Aug 22, 2018, 02:37 AM https://forums.modx.com/thread/104294/recaptcha-v2-no-longer-works-on-multiple-sites-after-modx-2-6-5-upgrade#dis-post-560986
<![CDATA[Re: reCaptcha V2 no longer works on multiple sites after MODx 2.6.5 upgrade]]> https://forums.modx.com/thread/104294/recaptcha-v2-no-longer-works-on-multiple-sites-after-modx-2-6-5-upgrade#dis-post-560965 Quote from: BobRay at Aug 20, 2018, 10:44 PM
On the original error, there should be a property called &modelPath in the FormIt tag (or the FormIt snippet properties).

My wild guess is that the property is missing or has an incorrect value.

I believe it's supposed to hold the path to core/components/formit/model/

Forgive my ignorance, Bob, but is there anything I can do to correct this? This is happening on multiple sites. The sites had been working okay before the upgrades.]]>
waizen Aug 21, 2018, 12:23 PM https://forums.modx.com/thread/104294/recaptcha-v2-no-longer-works-on-multiple-sites-after-modx-2-6-5-upgrade#dis-post-560965
<![CDATA[Re: reCaptcha V2 no longer works on multiple sites after MODx 2.6.5 upgrade]]> https://forums.modx.com/thread/104294/recaptcha-v2-no-longer-works-on-multiple-sites-after-modx-2-6-5-upgrade#dis-post-560952
My wild guess is that the property is missing or has an incorrect value.

I believe it's supposed to hold the path to core/components/formit/model/]]>
BobRay Aug 20, 2018, 10:44 PM https://forums.modx.com/thread/104294/recaptcha-v2-no-longer-works-on-multiple-sites-after-modx-2-6-5-upgrade#dis-post-560952