code snippet executing twice in hook frm_validate_field_entry

By: Jay Mac | Asked: 02/23/2023
ForumsCategory: General questionscode snippet executing twice in hook frm_validate_field_entry
Jay Mac asked 2 years ago
Hi -   I have a code snippet that uses the hook frm_validate_field_entry which the documentation states runs after each time the submit button is clicked. I have a two page form, the first page has a CONTINUE button does that count as a submit? My code checks the form_id (deriving it from the form_key) to ensure it only executes on one form and it checks the field_id (deriving it from the field_key) so it only executes for that one field. The snippet then creates a AWS S3 bucket name and then runs a PHP curl to create the bucket. The problem is the debug log shows bucket names that don't align with buckets that are created and it creates 2 buckets instead of one.  The only thing I can think of is that it is somehow executing the code more than one because of that continue button. Any insights or thoughts?   Thanks
Rob LeVineRob LeVine replied 2 years ago

Can you upload your code to something like https://paste2.org/ and paste the link here?

Jay Mac replied 2 years ago

see answer=comment below

1 Answers
Jay Mac answered 2 years ago

Thanks Rob - I found it was the if test with the die command after the curl command  that was causing the problem$result = curl_exec($curl);if(!$result){die("Connection Failure In CallBucketCreate");}

Making the Best WordPress Plugin even better - Together

Take on bigger projects with confidence knowing you have access to an entire community of Formidable Experts and Professionals who have your back when the going gets tough. You got this!
Join the community
crossarrow-right