Skip Navigation

[Resolved] Post Form occasionally fail to save

This support ticket is created 2 years, 8 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Karachi (GMT+05:00)

This topic contains 25 replies, has 2 voices.

Last updated by Waqar 2 years, 7 months ago.

Assisted by: Waqar.

Author
Posts
#2303353

samedaywindshield.com receives a relatively high volume of post form submissions, approximately 30 to 50 per day.

Occasionally, the client will receive email notifications from the system that do not get recorded as new posts. The server does not show the new post and there is no record in the Post SMTP plugin that the emails were ever sent.

I can tell by the contents of the emails that they come from this website, but it's as if the event never happened.

Do you know how or why this might happen?

#2303355

The text from the email notifications from one of these missed posts is:

Wpcf-csr-code
0000BND
Wpcf-referring-url
hidden link
Wpcf-source-domain
hidden link{campaign}&gclid=Cj0KCQiAmeKQBhDvARIsAHJ7mF5Kp9iu3rfa6wJotRzBCf_j06grD2EJnUrpJFVLqB-adeF5ny3qotgaAsf4EALw_wcB
Post Title
Gavin - 8638126136
Wpcf-campaign
{campaign}
Wpcf-keyword
safelite
First Name*
Gavin
Last Name*
Hall
Phone*
8638126136
Email
remmmebaileyboo@gmail.com
Manufacturer
Ford
Model
EcoSport
Vehicle Year
2020
Which Glass Is Broken?
Front windshield
Insurance Company
Geico
Policy Number If Available
4558377356
G-recaptcha-response
03AGdBq25b-sTwjzpfWBUpY78HfHYHJ0sqe7w--3SIa6TrDgsnpdfAvfXi5UA9Km2Y7Y_BbIJRySySH9o_VhM2s6n5wvK6E8_B1bOEFyPVGHDqVcuV0PQzFRW12v79PZuRYt2qrAxXF61Bkx4PMoSme-VXNzTEAy4e9j1iXrncZSzd9gA8ZEnmlwWT-XM7etxLDkXo0CAJLpZqEeWYjWUsa4h4mWH5M1F_iKOtAsFLnCT8yjAKW6A1tGrYFTVrZR6nKbKfIaKX-wQKOEVTv57pv868HwlMF_7HpDbRwxdE3gx0ofwBpB-ibriDCVRMq_Viwp0zOzC7bXFOFw94Clym0JSmFQbenJMM5EfHQut2KyW4BAzn75VpPjsaP2o04fefWRRah_ubojPcDZM-ur8wyChUnpG6G69jmEDbeabbR_G8CYlpBUYrk1A9o0Q-Qop_CoFfAyIIwEFz9BalunH2LTu_2mH0ZhgnWNN_NOTlGS4y6TQwLFv7-AjoPw-XciXuMDNNkpo5XPeuo25JaHf-p9STKsvDH2Kz7Vb_5dTxEZtuUTzAJkh6BmOeWsbbT7JxkvJEnT9nTk_m
Cred Cred Prefix Post Id
82395
_cred_cred_prefix_cred_container_id
9808
Cred Cred Prefix Form Id
12278
Cred Cred Prefix Form Count
1
Apbct Visible Fields
{"0":{"visible_fields":"wpcf-msclkid wpcf-gclid wpcf-csr-code wpcf-referring-url wpcf-source-domain post_title wpcf-campaign wpcf-keyword wpcf-first-name wpcf-last-name wpcf-phone wpcf-email wpcf-vehicle-manufacturer wpcf-vehicle-model wpcf-vehicle-year wpcf-which-glass-is-broken wpcf-insurance-company wpcf-policy-number","visible_fields_count":18,"invisible_fields":"g-recaptcha-response _cred_cred_prefix_post_id _cred_cred_prefix_cred_container_id _cred_cred_prefix_form_id _cred_cred_prefix_form_count","invisible_fields_count":5}}

#2303357

An email notification example from the posts that do save looks like this:

Referring URL: hidden link
Source Domain: hidden link
Rep Code: ****Check Form Submissions In CallRail****

Username: Randall
Phone: 8134516260
Email: randallpspitler@gmail.com
Vehicle Year:
Vehicle Model:
Vehicle Manufacturer:
Glass Broken:
Insurance Company:
Policy Number:

Campaign: {campaign}
Keyword: safelite

#2303799

I've implimented reCaptcha v3 using the plugin CAPTCHA 4WP. I have included a shortcode - [anr-captcha] in the Toolset forms.

Is there something else I need to add in order to get this functioning correctly? It seems that, if recapcha passes, the form works but, if it fails, it's just emailing the results without saving the post or displaying the recaptcha challenge.

Perhaps I am missing a handler for when the reCaptcha fails.

#2304647

Hi,

Thank you for contacting us and I'd be happy to assist.

The 'CAPTCHA 4WP' plugin doesn't officially support integration with the Toolset Forms. During some research, I found that it offers a function "anr_verify_captcha", which can be used to validate the captcha response:
hidden link

You can use the Toolset's "cred_form_validate" hook to add a function that adds a validation error message if 'anr_verify_captcha' returns false:
https://toolset.com/documentation/programmer-reference/cred-api/#cred_form_validate

I hope this helps and please let me know if you need any further assistance around this.

regards,
Waqar

#2305097

Can you direct me to an example of the function I need to write for this?

#2305649

Here is an example of the function from the documentation of the 'cred_form_validate' hook:
https://toolset.com/documentation/programmer-reference/cred-api/#cred_form_validate

I've updated it so that it shows the error message if the captcha response has not been verified:


add_filter('cred_form_validate','my_validation',10,2);
function my_validation($error_fields, $form_data)
{
	//field data are field values and errors
	list($fields,$errors)=$error_fields;

	//validate if specific form
	if ($form_data['id']==12345)
	{
		if (! anr_verify_captcha() ) {
			$errors['post_title']='Captcha not verified!';
		}
	}
	//return result
	return array($fields,$errors);
}

Note: You'll replace '12345' with the actual ID of your form. This code snippet can be included through either Toolset's custom code feature ( ref: https://toolset.com/documentation/adding-custom-code/using-toolset-to-add-custom-code/ ) or through the active theme's "functions.php" file.

Important: As the captcha field is not a built-in field, it is not recognized by the form's validation system. In this example, I've linked the display of the error message with the post's title field 'post_title'. This means that for the captcha field error message to appear, it is important that your form also includes the post title field.

The custom code examples from our forum are shared to get you started in the right direction. You're welcome to adjust them as needed and for more personalized customization assistance, you can consider hiring a professional from our list of recommended contractors:
https://toolset.com/contractors/

#2307733

I currently have the post title field in the form, but in a hidden div. I have some JavaScript setting the post title to some values from other, visible fields. Will it work if I keep the title in the hidden div?

#2308277

Yes, the code should work, even if the post title field is in a hidden div.

#2308771

I've installed the code and adjusted the form IDs accordingly on samedaywindshield.com

Today at 11:26 am CST, we had a lead that did send emails but failed to save. The contents received in the email are similar to all saved leads up until the line containing "G-recaptcha-response..." Thereafter, the contents of the email differ from those that were saved as outlined above.

Something is causing Toolset to send the emails but not save the form.

#2310001

In that case, I'll recommend removing the 'CAPTCHA 4WP' plugin's captcha from the form and see, if you still get any email notifications, without a saved post.

This test will help narrow it down, whether this is due to the unsupported captcha plugin or something else.

If the issue is fixed when this third-party captcha is removed, it would be best to use the built-in captcha feature for the Toolset forms:
https://toolset.com/course-lesson/protecting-forms-from-spam

#2310721

I started with Toolset's built-in reCaptcha, but learned that Toolset only supports v2 reCaptcha. My forms are located within the home page where it won't look right if I add the visible reCaptcha element. I need to use v3 or some method that doesn't alter the formatting of the basic form.

Since the emails that get sent when a form is not saved also contain a large block of text returned from the Google validation, doesn't that indicate that the problem is related to the Google code?

#2311279

I can understand the nature of your requirement, but unfortunately, reCaptcha V3 is something that is not officially supported, at the moment.

You're welcome to submit a feature request for this at:
https://toolset.com/home/contact-us/suggest-a-new-feature-for-toolset/

I tried to guide you with the validation custom code, but, if it is still not working, it means that this will need deeper level integration from developers on both sides ( 'CAPTCHA 4WP' and Toolset plugins ).

Until that happens, I'm afraid, you'll have to use a different form plugin that supports the reCaptcha V3 or any other invisible reCaptcha, for that one form on the homepage.

#2313431

I have disabled the reCaptcha entirely from the form. We are still seeing Toolset send notifications but fail to save the form data. This happens about 1 out of 50 submissions. Can you help me figure out why Toolset is failing to save leads?

#2313703

The email contents from several examples of forms that fails to save are as follows. Note that there are no errors in the WordPress logs.
#1:
Mar 9 5:00pm:

Wpcf Csr Code 0000BND
Post Title Mary Ann - 813-833-4737
Wpcf Campaign Search | FL Tampa (Clearwater) | Desktop
Wpcf Keyword auto glass repair
First Name* Mary Ann
Last Name* Whallen
Phone* 813-833-4737
Email Mawhallen@gmail.com
Manufacturer Nisson
Model Pathfinder
Vehicle Year 2014
Which Glass Is Broken? Windshield
Insurance Company Esurance
Cred Cred Prefix Post 92543
Cred Cred Prefix Cred Container 9820
Cred Cred Prefix Form 12278
Cred Cred Prefix Form Count 1
Apbct Visible Fields {"0":{"visible_fields":"wpcf-msclkid wpcf-gclid wpcf-csr-code wpcf-referring-url wpcf-source-domain post_title wpcf-campaign wpcf-keyword wpcf-first-name wpcf-last-name wpcf-phone wpcf-email wpcf-vehicle-manufacturer wpcf-vehicle-model wpcf-vehicle-year wpcf-which-glass-is-broken wpcf-insurance-company wpcf-policy-number","visible_fields_count":18,"invisible_fields":"_cred_cred_prefix_post_id _cred_cred_prefix_cred_container_id _cred_cred_prefix_form_id _cred_cred_prefix_form_count","invisible_fields_count":4}}

#2
Mar 9 4:44pm:
Wpcf Csr Code 0000BND
Post Title Daniel - 938-999-8121
First Name* Daniel
Last Name* Wright
Phone* 938-999-8121
Email Wright3470@gmail.com
Cred Cred Prefix Post 92536
Cred Cred Prefix Cred Container 9772
Cred Cred Prefix Form 12208
Cred Cred Prefix Form Count 1
Apbct Visible Fields {"0":{"visible_fields":"wpcf-msclkid wpcf-gclid wpcf-csr-code wpcf-referring-url wpcf-source-domain post_title wpcf-campaign wpcf-keyword wpcf-first-name wpcf-last-name wpcf-phone wpcf-email","visible_fields_count":12,"invisible_fields":"_cred_cred_prefix_post_id _cred_cred_prefix_cred_container_id _cred_cred_prefix_form_id _cred_cred_prefix_form_count","invisible_fields_count":4}}

#3
Mar 10 2:08pm:
Wpcf-gclid CjwKCAiA4KaRBhBdEiwAZi1zzj3HXKalD4YzKfqfT3zL1LlHuTyTZxQ214I0nzwHyiGbO9r8l-M8IhoCRvoQAvD_BwE
Wpcf-csr-code 0000BND
Wpcf-source-domain hidden link
Wpcf-campaign {campaign}
Wpcf-keyword safelite
First Name* Natalie
Last Name* Prophet
Phone* 9544448426
Email Nmerus86@gmail.com
Manufacturer Land Rover
Model Range Rover
Vehicle Year 2017
Which Glass Is Broken? Front Windshield
Cred Cred Prefix Post Id 93173
_cred_cred_prefix_cred_container_id 9808
Cred Cred Prefix Form Id 12278
Cred Cred Prefix Form Count 1
Apbct Visible Fields {"0":{"visible_fields":"wpcf-msclkid wpcf-gclid wpcf-csr-code wpcf-referring-url wpcf-source-domain post_title wpcf-campaign wpcf-keyword wpcf-first-name wpcf-last-name wpcf-phone wpcf-email wpcf-vehicle-manufacturer wpcf-vehicle-model wpcf-vehicle-year wpcf-which-glass-is-broken wpcf-insurance-company wpcf-policy-number","visible_fields_count":18,"invisible_fields":"_cred_cred_prefix_post_id _cred_cred_prefix_cred_container_id _cred_cred_prefix_form_id _cred_cred_prefix_form_count","invisible_fields_count":4}}