frm_filter_where_val

Back to Top
Knowledge BaseDisplay Data → frm_filter_where_val

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. This hook will also affect the filter whether it is performed on a post field or a regular field.

Usage

add_filter('frm_filter_where_val', 'frm_filter_where_val', 8, 2);

Parameters

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

Examples

Formidable Hook - Helpful

Check each value from checkbox

Submitted by  — 8 years ago

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;
}
Formidable Hook - Helpful

Set a custom filter value

Submitted by  — 8 years ago

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;
}
Formidable Hook - Helpful

Remove characters from filter value

Submitted by  — 8 years ago

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;
}
If you would like to add your own example, click here.

Have something to add?

Click here to provide feedback on this page.