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_view

Last Updated: April 30, 2018

Knowledge Base → Extend Formidable Forms → Formidable Hooks - for Developers → Display Data → frm_filter_view
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.

The frm_filter_view hook allows you to modify any part of the View object before the View is rendered.

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

Usage

add_filter( 'frm_filter_view', 'change_my_view_object', 10, 1);

Parameters

  • $view (object)

Examples

Change View order based on URL parameter

Use the following code to change a View's order when a specific URL parameter and value are set. Replace 123 with the ID of your View, replace my_param with your parameter name, replace custom_value with your specific parameter value, and replace 150 with the ID of the field you want to order by.

add_filter( 'frm_filter_view', 'change_my_view_object', 10, 1);
function change_my_view_object( $view ) {
	if ( $view->ID === 123 ) {
		if ( isset( $_GET['my_param'] ) && $_GET['my_param'] == 'custom_value' ) {
			$view->frm_order_by = array( 150 );
			$view->frm_order = array( 'DESC' );
		}
	}

	return $view;
}

Check if a user exists or not

Use the following code to have a View that shows items connected to a user existing in the database.

add_filter('frm_filter_view', 'check_if_users_exists', 10, 2);
function check_if_users_exists( $view ) {
	$target_view_id = 380; // change this to your View ID.
	if ( $target_view_id !== (int) $view->ID ) {
		return $view;
	}

	$target_form_id = $view->frm_form_id;

	global $wpdb;
	$item_ids = FrmDb::get_col( $wpdb->prefix . 'frm_items i INNER JOIN ' . $wpdb->prefix . 'users u ON u.ID = i.user_id', array( 'i.form_id' => $target_form_id ), 'i.id' );

	$view->frm_where = array( 'id' );
	$view->frm_where_is = array( 'in' );
	$view->frm_where_val = array( implode( ',', $item_ids ) );

	return $view;
}

If you want to make a View that only shows the users that don't exist, change this line of code:
$view->frm_where_is = array( 'in' );
to
$view->frm_where_is = array( 'not in' );

Change Log

Added in version 2.02.13
  • Usage
  • Parameters
  • Examples
    • Change View order based on URL parameter
    • Check if a user exists or not
  • Change Log
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