gravityflow_field_filters_status_table

The gravityflow_field_filters_status_table filter is used to constrain which forms' fields are displayed in the drop-down list on the status table in shortcode or admin view.

Parameters

$field_filters array

Examples

Example 1 - Remove specific field from specific form

The following snippet will remove field ID #1 from form ID #27 from being displayed in the filter dropdown list.

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;
}

Example 2 - Add option to 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 have use if you are setting expirations on your steps and not defining the status after expiration as complete.

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;
}

Example 3 - Remove default form / 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.

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 should be placed in the functions.php file of your active theme.