Description
The gravityflow_field_filters_status_table filter is used to constrain which form fields are displayed in the drop-down list on the status table in shortcode or admin view.
Parameters
Parameter | Type | Details |
---|---|---|
$field_filters | Array | An associative array of filters by Form ID. |
Examples
Remove specific fields from specific forms
The following snippet will remove field ID #1 from form ID #27 from being displayed in the filter dropdown list.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | add_filter( 'gravityflow_field_filters_status_table' , 'field_filters_remove_names' , 10, 1 ); function field_filters_remove_names( $field_filters ) { foreach ( $field_filters as $form => $fields ) { if ( $form == '27' ) { $position = 0; foreach ( $fields as $key => $field ) { if ( $field [ 'key' ] == '1' ) { array_splice ( $field_filters [ $form ], $key , $position ); } $position ++; } } } return $field_filters ; } |
Add option to a specific form
The following snippet will add an ‘Expired’ option to every Step Status choice for form 27 in the filter dropdown list.
This would only be used if you set expirations on your steps and not define the status after expiration as complete.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | add_filter( 'gravityflow_field_filters_status_table' , 'field_filters_status_expired' , 10, 1 ); function field_filters_status_expired( $field_filters ) { foreach ( $field_filters as $form => $filters ) { if ( $form == '27' ) { $position = 0; foreach ( $filters as $key => $filter ) { if ( false !== strpos ( $filter [ 'key' ], 'workflow_step_status' ) ) { $field_filters [ $form ][ $key ][ 'values' ][] = array ( 'value' => 'expired' , 'text' => 'Expired' , ); } $position ++; } } } return $field_filters ; } |
Remove default form or status options from all
The following snippet will remove common form meta data (IP, creation date, source url, etc) as well as any of the workflow step status filters for all form filter selections. You might use this if you want to present a limited set of options to front-end users. Note that it checks whether the status page is showing on the admin view or not before modifying the filters.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 | add_filter( 'gravityflow_field_filters_status_table' , 'field_filters_remove_defaults' , 10, 1 ); function field_filters_remove_defaults( $field_filters ) { if ( is_admin() ) { return $field_filters ; } $reserved_filters = array ( 'ip' , 'is_starred' , 'created_by' , 'payment_status' , 'payment_date' , 'source_url' , 'transaction_id' , 'payment_amount' , ); foreach ( $field_filters as $form => $fields ) { $modify = false; foreach ( $fields as $key => $field ) { if ( in_array( $field [ 'key' ], $reserved_filters ) || strpos ( $field [ 'key' ], 'workflow_step_status' ) !== false ) { unset( $field_filters [ $form ][ $key ] ); $modify = true; } } if ( $modify ) { $field_filters [ $form ] = array_values ( $field_filters [ $form ] ); } } return $field_filters ; } |
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?