Formidable Forms

Formidable Forms

  • Features
  • Pricing
  • Resources
    • Docs & Support
    • Blog
    • Community
  • Solutions
    • Web Applications
    • Calculators
    • Surveys
    • Directories
    • Payments
    • Contact forms
  • Login
  • Get Formidable Forms

frm_filter_where_val

Last Updated: October 9, 2018

Knowledge Base → Extend Formidable Forms → Formidable Hooks - for Developers → Display Data → frm_filter_where_val
Heads up!
This article contains PHP code and is intended for developers. We offer this code as a courtesy, but don't provide support for code customizations or 3rd party development.

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.

Formidable Forms is the best WordPress Form Builder plugin. Get it for free!

Usage

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

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.

This code example can be used for any situation where you want to search multiple, comma-separated values.

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;
}
  • Usage
  • Parameters
  • Examples
    • Check each value from checkbox
    • Set a custom filter value
    • Remove characters from filter value
Categories
×

Categories

  • Installation & Getting Started
  • Account Management
  • Forms
  • Entries
  • Views
  • Styles
  • Importing & Exporting
  • Add-Ons
  • Extend Formidable Forms

Using WordPress and want to get Formidable Forms for free?

Get Formidable Forms Lite Now

You do not have permission to view this form. Maybe you need to log in?

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.

Take on bigger projects Right Now

Get the tools you need to revolutionize your workflow and architect a masterpiece. Build the most advanced WordPress forms and actually use the data you collect in meaningful ways.

Get the most advanced WordPress form plugin and the only form builder with integrated Views.

Get Formidable Forms Now

Resources

  • Community
  • Affiliates
  • Contact
  • Free Online Form Builder

Top Features

  • Application Builder
  • Calculator Forms
  • Surveys & Polls
  • Quiz Maker
  • Form Templates
  • Application Templates
  • Directories
  • Donation Plugin

Company

  • About Us
  • Giving Back
  • Careers
  • Newsletter
  • WP Tasty
  • Nutrifox

Copyright © 2023 Strategy11, LLC. Formidable Forms® is a registered trademark Strategy11, LLC.
Privacy Policy | Terms of Service | Sitemap

Join 300,000+ using Formidable Forms to create form-focused solutions fast. Get Started See User Reviews