gravityflow_timeline_notes

The gravityflow_timeline_notes filter allows you to customize the entries of the activity log for a given entry/workflow, before they are presented in multiple locations including the entry detail screen and {workflow_timeline} merge tag.

Parameters

Parameter Type Definition
$notes Array The array of timeline notes in reverse chronologicalentry array.
$entry Array The current entry array.

Examples

Example 1 - Display in chronological order

This will sort the timeline entries in chronological order (oldest = first).

add_filter( 'gravityflow_timeline_notes', 'jo_timeline_reverse', 10, 2 );
function jo_timeline_reverse( $notes, $entry ) {
    $notes = array_reverse( $notes );
    return $notes;
}

Example 2 - Display the full date/timestamp on each note

This will sort the timeline entries in chronological order (oldest = first).

add_filter( 'gravityflow_timeline_notes', 'jo_timeline_granular', 10, 2 );
function jo_timeline_granular( $notes, $entry ) {
	foreach ( $notes as &$note ) {
		$magic = true;
		$note->value = $note->date_created . ' - ' . $note->value;
	}
	return $notes;
}

Example 3 - Restrict certain note types from the timeline outside the WP admin dashboard

This will remove any timeline entries based on their type in certain display conditions such as checking for is_admin() page or not.

add_filter('gravityflow_timeline_notes', 'jo_remove_workflow_notes', 10, 2);
function jo_remove_workflow_notes($notes, $entry) {

	// Check whether timeline is attempting to render on WP admin page or front-end
	// Perhaps it is also useful to compare $entry['form_id'] to further restrict when this filter is applied
	if ( ! is_admin() ) {
		foreach ($notes as $key => $note ) {
			// Remove notes created by the outgoing webhook step type
			if ( isset( $note->user_name ) && $note->user_name == 'webhook' ) {
				unset( $notes[$key] );
			}
		}
	}
	return $notes;
}

Placement

This code should be placed in the functions.php file of your active theme or in a custom functions plugin.