Description
The gravityflow_status_filter filter is used to constrain the entries on the status page.
Parameters
Parameter | Type | Details |
---|---|---|
$filter_constraints | Array | The array of constraints such as form_id, start_date or end_date that status page should be filtered through. |
Examples
Restricts entries by created user and form ID
add_filter( 'gravityflow_status_filter', 'sh_gravityflow_status_filter' );
function sh_gravityflow_status_filter( $filter_constraints ) {
$user = wp_get_current_user();
if ( $user->ID == 1 ) {
// The constraints are optional.
$filter_constraints = array(
'form_id' => 2,
// 'start_date' => '2016-01-01',
// 'end_date' => '2016-01-14',
);
}
return $filter_constraints;
}
Restrict entries based on specific field value
Refer to the Gravity Forms API docs for further field filter examples.
add_filter( 'gravityflow_status_filter', 'sh_gravityflow_status_field_filter' );
function sh_gravityflow_status_field_filter( $filter_constraints ) {
$filter_constraints = array(
'field_filters' => array(
'mode' => 'all',
array(
'key' => 9,
'operator' => 'isnot',
'value' => 'Ontario'
)
)
);
return $filter_constraints;
}
Shortcode and form_id specification
When working with shortcodes, the filter must be specified with the form_id to ensure the shortcode works in collaboration with it.
For this shortcode : [gravityflow page=”status” form=”5″ fields=”1,2″ id_column=”false”], where we restrict status view to have values of fields of 1 and 2 only. A further requirement of only displaying the fields with value in field 1 as ‘Hello’ will be done as shown below. Please note without specifying the form_id in filter, it will work to process the data of all forms.
add_filter( 'gravityflow_status_filter','sh_gravityflow_status_field_filter' );
function sh_gravityflow_status_field_filter( $filter_constraints ) {
$filter_constraints = array(
'field_filters' => array(
'mode' => 'all',
array(
'key' => 1,
'operator' => 'is',
'value' => 'Hello'
)
),
'form_id' => 5
);
return $filter_constraints;
}
Placement
This code can be used in the functions.php file of the active theme, a custom functions plugin, a custom add-on, or with a code snippets plugin.
See also the PHP section in this article: Where Do I Put This Code?