Skip to content

Instantly share code, notes, and snippets.

@Idealien
Created February 2, 2018 20:57
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save Idealien/47c2a248386ed062782b3d2748dd439a to your computer and use it in GitHub Desktop.
Save Idealien/47c2a248386ed062782b3d2748dd439a to your computer and use it in GitHub Desktop.
Gravity Flow - Step Assignee - Bypass "re-assignment" with email change
<?php
add_filter( 'gravityflow_step_assignees', 'bypass_step_assignee_on_email_change', 10, 2 );
function bypass_step_assignee_on_email_change( $assignees, $step ) {
//Update with the ID of your specific step to apply the bypass against
if ( $step->get_id() == '76' ) {
if ( isset( $_POST['gforms_save_entry'] ) && count( $_POST ) > 0 ) {
$reset = false;
if ( $assignees ) {
foreach ( $assignees as $key => $assignee ) {
//Update with the field ID of your email field in place of input_1
if ( $assignee->get_type() == 'email' && isset( $_POST['input_1'] ) && $_POST['input_1'] == $assignee->get_id() ) {
$reset = true;
}
}
}
if ( $reset ) {
gravity_flow()->log_debug( __METHOD__ . '(): Bypassing assignee for step completion (email change scenario)' );
$assignees = array();
}
}
}
return $assignees;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment