Skip to content

Instantly share code, notes, and snippets.

@phillipwilhelm
Forked from Idealien/functions.php
Created March 28, 2020 04:48
Show Gist options
  • Save phillipwilhelm/31bf94f6d7f1abebcead22f88e125f41 to your computer and use it in GitHub Desktop.
Save phillipwilhelm/31bf94f6d7f1abebcead22f88e125f41 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