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 | Entry | The current entry array. |
Examples
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;
}
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;
}
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 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?