Description
The gravityflow_admin_action_feedback filter can process custom choices from the admin actions drop-down menu on the workflow detail page. To populate the drop-down menu with custom actions, use the gravityflow_admin_actions_workflow_detail filter.
Parameters
Parameter | Type | Details |
---|---|---|
$feedback | String or WP_Error | A string with the feedback to be displayed to the user or an instance of WP_Error. |
$admin_action | String | The current admin action attempting to be processed. |
$form | Form Object | The current form. |
$entry | Entry Object | The current entry. |
Examples
Cancel a completed workflow
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | 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 ; } |
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?