gravityflow_feedback_approval

Use this filter to change the text of the  feedback message on the approval  step.

Parameter Type Definition
$feedback String The feedback to send to the browser.
$entry Array The current entry array.
$assignee Gravity_Flow_Assignee The assignee object.
$new_status String The new status
$form Array The current form array.
$step Gravity_Flow_Step The current step

Example #1: Display custom message

The  following example will change the message to "Thank you very much!" specifically for step with ID 12.

add_filter( 'gravityflow_feedback_approval', 'sh_gravityflow_feedback_approval', 10, 6 );  
function sh_gravityflow_feedback_approval( $feedback,  $entry, $assignee, $new_status, $form, $step ) { 
    if ( $step->get_id() == '12' ) {$feedback = 'Thank you very much!';}
	return $feedback;
}

NOTE: This filter will only run when the approval buttons are clicked on the workflow detail page. If you want to modify the feedback for the one-click approval links, you need to use the gravityflow_feedback_approval_token filter which takes the same arguments.

Example #2: Customize user field for subsequent step assignment

When the approval step has been approved, this filter updates a user field in the form (who will get next step assigned) and adds a unique note to the timeline. Ordinarily this type of logic would fit better in gravityflow_step_complete but the need to evaluate approval status combined with assignee modification and additional note led to it occurring earlier in the processing cycle.

add_filter( 'gravityflow_feedback_approval', 'jo_define_approver_to_field', 10, 6 );
function jo_define_approver_to_field( $feedback, $entry, $assignee, $new_status, $form, $step ) {

	//Modify this to match the step ID of your approval step that needs customization.
	$step_id_approval = 570;
	//Modify this to match the field ID of the user field that you add to your form. It will be what your post-approval step gets assigned to.
	$field_id_user    = 4;

	if ( $step->get_id() !== $step_id_approval ) {
		return $feedback;
	}

	if ( $new_status == 'approved' ) {
		$user = get_user_by( 'ID', $assignee->get_id() );
		if ( $user ) {
			GFAPI::update_entry_field( $entry['id'], $field_id_user, $user->ID );
			$note = sprintf( esc_html__( 'Updating Post-Approval Step Assignee to: %s (%s)' ), $user->display_name, $user->ID );
			$step->add_note( $note, true );
		}
	}

	return $feedback;
}

Placement

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