• Resolved jaidenf

    (@jaidenf)


    I’ve set up a form that has calculations and I want to show specific messages depending on the score.

    I’ve tested the shortcodes work on the same page confirmation message. But I want them to work on my redirected page. The data is being passed correctly, but it isn’t working.

    Data IS shown if I use “get” – for example [ff_get param=”score_total”] will show the score.

    But I want [ff_if] shortcodes to actually work (like they do on the normal form confirmation page) – example [ff_if field=”score_total” is=”less_or_equal” to=”8″] Your score is Low (4-8). Blahblahblah [/ff_if]

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Support Amimul Ihsan

    (@amimulihsanmahdi)

    Hello @jaidenf,

    Fluent Forms conditional shortcode will only work on th confirmation message and email notification. Unfortunately, it will not work on a WordPress page.

    Thank you

    Thread Starter jaidenf

    (@jaidenf)

    Is there any way around this? I’m happy to figure out the code if that’s needed.

    Another workaround I could do, is create a elementor template (with the conditional shortcode) and add it’s shortcode on confirmation page. But it seems fluent forms strip all the styles and code from it?

    Thread Starter jaidenf

    (@jaidenf)

    SOLUTION: I created my own conditional shortcodes that read the query param amount. Code is below with a shortcode example (make sure your query data string is correct in FF and shortcode).

    [show_if param=”score_total” operator=”greater_equal” value=”10″]
    Over 10
    [/show_if]

    function display_content_based_on_query($atts, $content = null) {
    $param_name = isset($atts['param']) ? sanitize_text_field($atts['param']) : '';
    $param_value = isset($_GET[$param_name]) ? sanitize_text_field($_GET[$param_name]) : '';

    if (!$param_name || $param_value === '') {
    return ''; // Hide content if parameter is missing
    }

    $operator = isset($atts['operator']) ? $atts['operator'] : 'equals';
    $value = isset($atts['value']) ? sanitize_text_field($atts['value']) : '';

    $should_show = false;

    switch ($operator) {
    case 'greater':
    $should_show = ((float)$param_value > (float)$value);
    break;
    case 'greater_equal':
    $should_show = ((float)$param_value >= (float)$value);
    break;
    case 'less':
    $should_show = ((float)$param_value < (float)$value);
    break;
    case 'less_equal':
    $should_show = ((float)$param_value <= (float)$value);
    break;
    case 'not_equals':
    $should_show = ($param_value != $value);
    break;
    case 'contains':
    $should_show = (strpos($param_value, $value) !== false);
    break;
    case 'not_contains':
    $should_show = (strpos($param_value, $value) === false);
    break;
    case 'equals':
    default:
    $should_show = ($param_value == $value);
    break;
    }

    return $should_show ? do_shortcode($content) : '';
    }
    add_shortcode('show_if', 'display_content_based_on_query');

    Plugin Support Amimul Ihsan

    (@amimulihsanmahdi)

    Hello again,

    Thank you for sharing your solution with the community! ?? Your contribution will surely help others facing a similar challenge. We appreciate you taking the time to post it! ??

    Thank you

Viewing 4 replies - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.