gravityflow_field_value_status_table

The gravityflow_field_value_status_table filter can be used to override the values which appears in the columns of the Workflow status table.

Parameters

$label     string

The value that is to be displayed.

$form_id  integer

The Form ID of the entry for the current row.

$column_name     string

The id of the column currently being processed.

$entry   Entry Object

The entry for the current row.

Examples

Example 1 - Replace the entry ID with the value from a form field.

add_filter( 'gravityflow_field_value_status_table', 'sh_gravityflow_field_value_status_table', 10, 4 );
function sh_gravityflow_field_value_status_table( $label, $form_id, $column_name, $entry ) {
	if ( $form_id == 2 && $column_name == 'id' ) {
		$label = rgar( $entry, '191' );
	}
	return $label;
}

Example 2 - Add an assignee column to Status tab

add_filter( 'gravityflow_columns_status_table', 'custom_column_titles', 10, 3 );
function custom_column_titles( $columns, $args, $table ) {
	$new_column = array(
		'assignees' => 'Assignee(s)',
	);
	$pre_columns = array_slice( $columns, 0, 2 );
	$post_columns = array_slice( $columns, 2 );
	$columns = array_merge( $pre_columns, $new_column, $post_columns );
	return $columns;
}

add_filter( 'gravityflow_field_value_status_table', 'custom_column_field_values', 10, 4 );
function custom_column_field_values( $value, $form_id, $column_name, $entry ) {

	if ( $column_name == 'assignees' ) {

		$api = new Gravity_Flow_API( $form_id );
		$step = $api->get_current_step( $entry );
		if( $step !== false ) {
			$assignees = $step->get_assignees();

			if ( $assignees ) {
				foreach( $assignees as $assignee) {
					if( $assignee->get_type() === 'user_id' ) {
						$value .= "<ul>";
						$value .= $assignee->get_user()->display_name;
						$value .= "</ul>";
					}
				}
			}
		}

	}

	return $value;
}

Example 3 - Customize the list field output

List fields can have multiple columns of info as well as multiple rows, which can often make it difficult to display the data within the status table. This example gives you 3 starting points to customize how you might want to present the list data.

add_filter( 'gravityflow_field_value_status_table', 'sh_reformat_value_lists', 10, 4 );
function sh_reformat_value_lists( $value, $form_id, $column_name, $entry ) {
	if ( $form_id == '76' && $column_name == '2' ) {
		//This would give you the html table version
		$value = html_entity_decode( $value );

		$form = GFAPI::get_form( $form_id );
		$field = GFFormsModel::get_field( $form, $column_name );
		if ( $field ) {
			//This will give you a , separated list of the values
			$value = $field->get_value_entry_detail( $entry['2'], '', false, $format = 'text', 'screen' );
		}

		//Or you can use custom code with this starting point to build your own based on the array.
		$list = maybe_unserialize( $entry['2'] );

		if ( ! empty( $list ) ) {
			$value = '<ul>';
			foreach ( $list as $row ) {
				$value .= '<li>';
				if ( is_array( $row ) ) {
					foreach ( $row as $column ) {
						$value .= '- ' . $column . '<br/>';
					}
				} else {
					$value .= $row;
				}
				$value .= '</li>';
			}
			$value .= '</ul>';
		}
	}

	return $value;
}

Placement

This code should be placed in the functions.php file of your active theme.