Formidable forms data - decision logic [if] to provide feedback based on form input

By: Sam Piper | Asked: 07/26/2023
ForumsCategory: Code HelpFormidable forms data - decision logic [if] to provide feedback based on form input
Sam Piper asked 1 year ago
I have a form developed using Formidable pro. I'm doing all of this in a view - post form submittal. I need to take 3 numerical values (Number fields) one of which is [age], and evaluate the other two - [target] and [current] (all are form values and have short codes) - to provide feedback to the user by presenting a custom data type post called "criteria." I have this working for other conditions based on calculated values using frm-math, frm-condition, less_than, and greater_than. The third dimension for age is killing me. Here is a line of one of the working examples:
> [frm-condition source=frm-math content="[270]" less_than=90
> greater_than=74][insert page='recommendation-yellow'
> display='content'] [/frm-condition]
What I need to do (logically) is say: if [age] greater_than=30 less_than=41 then evaluate these 3 criteria. In non-working pusdo code this:
if [age] greater_than=29 less_than=40 is 'true' then evaluate the following
if [current] l.t. [target * 2 ] [insert-page='red']
if [current] g.t. [target * 2 ] l.t. [target * 6] [insert-page='yellow']
if [current] g.t. [target * 6 ] [insert-page='green']
Then execute this same logic for the next age group 40's, 50's, and 60+. I can write this function in php in about 10 minutes. But I'm not WordPress smart enough to know where to put it so it works with my view, how to get to the data, set it up to run. I could not find a hook in Formidable that - based on the docs - looked like the right place to put this. If someone can point me toward some focused learning and give me some examples that would be great.
1 Answers
Best Answer
Victor Font answered 1 year ago
Since you're doing this in a view, a custom shortcode would work well. Pass your values to the shortcode and execute all of your logic at once in your callback. Return the formatted HTML or values to the view for display. Here's a link to the WordPress shortcode documentation.
Sam Piper replied 1 year ago

Hi Victor - thanks for the suggestion - looks good on first read. I'll give it a go today and report back.

Sam Piper replied 1 year ago

Hi Victor - Thanks for the help. That worked out well (you probably knew that). After reviewing the material about a custom shortcodes, I decided to use a custom plugin as a container rather than working in functions.php. I had previously tried a child theme to host my customization, but that came with a long list of other problems so the plug-in looked straight forward and it was.

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