gravityflow_admin_action_feedback

The gravityflow_admin_action_feedback filter can be used to process custom choices from the admin actions drop down on the workflow detail page. To populate the drop down with custom actions, use the  gravityflow_admin_actions_workflow_detail filter.

Parameters

$feedback  string|WP_Error

A string with the feedback to be displayed to the user or an instance of WP_Error.

$admin_actions     string

The current admin action attempting to be processed.

$form  Form Object

The current form.

$entry  Entry Object

The current entry.

Examples

Example 1

The following example shows how to cancel a completed workflow.
See Example 2 on gravityflow_admin_actions_workflow_detail for how to set the custom action the admin actions drop down.

add_filter( 'gravityflow_admin_action_feedback', 'sh_filter_admin_action_cancel_complete_workflow', 10, 4 );
function sh_filter_admin_action_cancel_complete_workflow( $feedback, $admin_action, $form, $entry ) {
	//Ensure the custom logic only executes for our desired admin action
	if( $admin_action != 'sh_cancel_completed_workflow') {
		return $feedback;
	}
	//Ensure the custom logic only executes for an entry in a complete status
	if( gform_get_meta( $entry['id'], 'workflow_final_status' ) == 'complete') {
		//Update the final status and provide appropriate feedback
		gform_update_meta( $entry['id'], 'workflow_final_status', 'cancelled' );
		$feedback = "The final status of entry has been updated to cancelled from complete.";
	} else {
		//Edge case coverage to inform user that criteria for action were not met
		$feedback = "The entry you selected was not in a complete status. No change to status made.";
	}

	return $feedback;
}