frm-field-value in a Conditional Statement not working as expected

By: Charl Van Niekerk | Asked: 04/27/2025
ForumsCategory: Code Helpfrm-field-value in a Conditional Statement not working as expected
Charl Van Niekerk asked 3 weeks ago

Hi People,

I'm just getting started with Formidable Forms, so I appreciate your patience.

Assistance would be greatly appreciated.

I have below line in my Views->details page.

[if frm-field-value field_id=49 entry=[250] equals="Dogs"]The specie is a dog related entry[/if frm-field-value]

So what Im trying to do is:

  1. Get a value from Form"A" entries and 
  2. Display a conditional value in a View -> details page, based on form "b"  entries

Formidible returns the following [if frm-field-value field_id=49 entry=11 equals=”Dogs”]This is a dog entry[/if frm-field-value]

What is the correct way of doing this or is my syntax incorrect.

 

 

 

2 Answers
Victor Font Staff answered 3 weeks ago

I suggest you read up on the shortcode you're trying to use. What is entry [250]? if you want to retrieve and entry from form A, the entry ID needs to be the entry id for form A.

Victor Font Staff replied 3 weeks ago

Also, I'm not sure you can use farm-field-value in a conditional the way you are using it. farm-field-value is a shortcode in and of itself. It needs to wrapped in own set of square brackets. An if is also it's own shortcode. You mat be better off writing your own shortcode.

Charl Van Niekerk replied 3 weeks ago

Hi Victor, thanks for your repose - think you are correct - frm-field-value cannot be used in an if statement.
regarding writing my own shortcode - I can do that, but as I'm new to Formidable, I'm scared that if there is a version change then my shortcode will not work anymore.

Victor, what is your experience regarding creating custom shortcodes?

Victor Font Staff replied 3 weeks ago

Formidable Masterminds is my website and Facebook group. I’ve been answering questions in the Formidable forums for more than a decade and have created more shortcodes than I can remember. I’ve never run into an issue of a shortcode not working because of a version change in WordPress or Formidable. There are literally thousands of hooks available in WordPress and Formidable to developers if they know how to use them.

Victor Font Staff replied 3 weeks ago

Formidable Masterminds is my website and Facebook group. I’ve been answering questions in the Formidable forums for more than a decade and have created more shortcodes than I can remember. I’ve never run into an issue of a shortcode not working because of a version change in WordPress or Formidable. There are literally thousands of hooks available in WordPress and Formidable to developers if they know how to use them.

Victor Font Staff replied 3 weeks ago

If you need help writing your shortcode, you can find a developer here: https://formidable-masterminds.com/developers-directory/.

Charl Van Niekerk replied 3 weeks ago

Much appreciated regarding your advice - will do that.

Charl Van Niekerk answered 3 weeks ago

Hi people, here is my solution curtesy of MS Copilot - whom wrote all the code and working like a dream.Much appreciated for all the help.  add_filter('frm_entries_list_query', 'filter_entries_by_field_and_form', 10, 2); function filter_entries_by_field_and_form($where, $args) {    global $wpdb;     $form_name = 'Application Form'; // Change this to the form name you want to search in    $field_id = 50; // Change to the field ID you want to filter by    $target_value = 'Approved'; // Change to the value you're filtering for     // Get the form ID based on the form name    $form_id = $wpdb->get_var($wpdb->prepare(        "SELECT id FROM {$wpdb->prefix}frm_forms WHERE name = %s",        $form_name    ));     if (!$form_id) {        return $where; // Exit without modifying the query if form name is invalid    }     // Get entry IDs where the field matches the target value    $entry_ids = $wpdb->get_col($wpdb->prepare(        "SELECT item_id FROM {$wpdb->prefix}frm_item_metas WHERE field_id = %d AND meta_value = %s",        $field_id, $target_value    ));     if (empty($entry_ids)) {        return $where; // Do not modify the query if no matching entries are found    }     $where['it.id'] = array_merge((array) $where['it.id'], $entry_ids); // Ensure existing entries are not removed    return $where;}

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