FSCF fails when modifying & outputting forms via PHP (sometimes)
-
I use
do_shortcode
in my theme to show an FSCF form. Based on certain conditions, hidden fields are added via PHP, and the recipient details are also changed.Here’s an example similar to what’s in the theme code:
<?php echo do_shortcode( '[si-contact-form form="1" hidden="Vegetable=' . $vegetable_list->ChosenVegetable . ',Meat=' . $meat_list->ChosenMeat . '" email_to="' . $chef_name . ',' . $chef_email . '"]' ); ?>
In this example, the theme should display FSCF contact form #1, and add two hidden fields — “Fruit” and “Vegetable” — pre-populated with content based on decoded JSON data. The form should also be set up to send to the right chef, using variables also based on decoded JSON data.
This works, most of the time.
The problem is that every so often, this type of form fails — i.e. instead of being sent to the chef, it would get sent to me, with no hidden fields added. It’s as if the form encounters some kind of error, and then defaults to the most basic settings that exist under Plugins > FS Contact Form > Form 1.
I’ve invested a bit of time into making FSCF work for this application, but the client is fairly important and can’t afford to have errors such as this.
I’d appreciate any help you can give. Do you know what may be happening, and what I can do to avoid the error?
Thank you.
- The topic ‘FSCF fails when modifying & outputting forms via PHP (sometimes)’ is closed to new replies.