Docs & Support

Learn about all the Formidable features and get support from our amazing customer success team.

frm_filter_where_val

Use this hook to customize a filter for a View. This hook will only apply to filters you have added in the "Advanced Settings" section of your View. This hook is similar to the frm_where_filter hook, but is fired earlier and changes only the value used before it is used in the full database query.

Usage

add_filter('frm_filter_where_val', 'frm_filter_where_val', 8, 2);
function frm_filter_where_val($where, $args)

Formidable Forms makes advanced site building simple. Launch forms, directories, dashboards, and custom WordPress apps faster than ever before.

Parameters

  • $where (string) The value used in the filter
  • $args (array) Includes 'display' (object), 'where_opt' (field id)

Examples

Check each value from checkbox

In order to use checkboxes in a search form, custom code is needed to separate each checked box and search for them individually instead of as a single string. For example, if I had a search form with boxes for 'red', 'blue', and 'yellow', I don’t want it to search for 'red, blue'. Replace 205 with the ID of your View. Replace 82, 83, and 84 with either a single field ID for the field in your View filter or multiple, comma-separated field IDs if you have multiple fields in your View filters that need this code.

add_filter('frm_filter_where_val', 'frm_search_multiple_values', 8, 2);
function frm_search_multiple_values($where, $args){
  if ( $args['display']->ID == 205 and in_array( $args['where_opt'], array( 82, 83, 84 ) ) ) {
    $where = explode(', ', $where);
  }
  return $where;
}

Set a custom filter value

Use the code below to set a custom filter value from the URL. Change 205 to your View ID, 84 to the ID of the field in the filter, and param_name to the name of the custom parameter in your URL.

add_filter('frm_filter_where_val', 'my_custom_filter_value', 8, 2);
function my_custom_filter_value( $where, $args ) {
  if ( $args['display']->ID == 205 && $args['where_opt'] == 84 && isset( $_GET['param_name'] ) && $_GET['param_name'] ) {
    $where = $_GET['param_name'];
  }
  return $where;
}

Remove characters from filter value

Use the code below to remove specific characters from a value in a filter. Change 205 to your View ID and change 84 to the ID of the field in the filter.

add_filter('frm_filter_where_val', 'remove_characters_from_filter_value', 8, 2);
function remove_characters_from_filter_value( $where_value, $args ) {
  if ( $args['display']->ID == 205 && $args['where_opt'] == 84 ) {
    $where_value = str_replace( array( 'amp;' ), '', $where_value );
  }
  return $where_value;
}
Was this article helpful? *

This article may contain affiliate links. Once in a while, we earn commissions from those links. But we only recommend products we like, with or without commissions.

In this article

    We have a small, but amazing team of dedicated people who are committed to helping you achieve your goals and project requirements.


    Copyright © 2025 Strategy11, LLC. Formidable Forms® is a registered trademark Strategy11, LLC.

    Complete your purchase
    Special offer unlocked.
    Get 55% OFF!
    Complete Purchase
    Join 400,000+ using Formidable Forms to create form-focused solutions fast. Get Formidable Forms