#main-content .container:before{background:none}#sidebar{display:none}@media (min-width:981px){#left-area{width:100%;padding:23px 0px 0px!important;float:none!important}}body:not(.et-tb) #main-content .container,body:not(.et-tb-has-header) #main-content .container{padding-top:5px!important}element.style{}.wp-block-toolset-blocks-container.tb-container[data-toolset-blocks-container="ed3832aa6201cbec5b1e5b902dc067e2"]{padding:5px!important}.et_pb_post .entry-content{padding-top:5px!important}.gform_required_legend{display:none}div.captcha-hidden{display:hidden;color:#741012;visibility:hidden}.captcha-hidden.label{display:hidden;color:#741012;visibility:hidden}@media only screen and (max-width:980px){.et_pb_column_0,.et_pb_column_1{padding-left:0px!important}.et_pb_section{padding:150px 0 5px 0!important}.et_pb_column .et_pb_row_inner,.et_pb_row{padding:10px 0 5px 0!important}.et_pb_section_0_tb_header{padding:10px 0 5px 0!important}.et_pb_menu--style-left_aligned.et_pb_text_align_center .et_pb_menu__wrap{-webkit-box-pack:right;-ms-flex-pack:right;justify-content:right}.et_pb_section_0_tb_footer{padding:10px 0 5px 0!important}.et_pb_row_0_tb_footer.et_pb_row{padding-top:5px!important;padding-bottom:5px!important;margin-top:0px!important;margin-right:auto!important;margin-bottom:0px!important;margin-left:auto!important;padding-top:50px;padding-bottom:150px}.et_pb_row_1_tb_footer{background-color:#000000;min-height:25px!important}.et_pb_text_0_tb_footer,.et_pb_social_media_follow_0_tb_footer,.et_pb_column_1_tb_footer{display:none}.et_pb_code_0_tb_footer,.et_pb_text_3_tb_footer,.et_pb_image_0_tb_footer,.et_pb_column_0_tb_footer{float:none!important;width:350px!important;margin:0 auto!important}.et_pb_image_0_tb_footer .et_pb_image_wrap img{width:350px!important;margin:0 auto!important}.et_pb_section_1,.et_pb_section_3{display:block}.et_pb_section_2{padding:0 0 5px 0!important}.et_pb_column{width:100%;margin-bottom:0px}#input_6_5{width:300px!important}}body #gform_wrapper_6{background-color:#741012}class GW_Round_Robin{private $_args=array();public function __construct($args=array()){// set our default arguments,parse against the provided arguments,and store for use throughout the class
$this->_args=wp_parse_args($args,array('form_id'=>6,'field_id'=>10,'hide_field'=>true,));// do version check in the init to make sure if GF is going to be loaded,it is already loaded
add_action('init',array($this,'init'))}public function init(){add_filter('gform_pre_render',array($this,'hide_round_robin_field'));add_filter('gform_entry_post_save',array($this,'apply_round_robin'),7,2);add_filter('gform_email_fields_notification_admin',array($this,'add_round_robin_field_to_notification_email_fields'),10,2)}public function hide_round_robin_field($form){if (! $this->_args['hide_field'] || ! $this->is_applicable_form($form)){return $form}foreach ($form['fields'] as &$field){if ($field->id==$this->_args['field_id']){$field->visibility='hidden'}}return $form}public function apply_round_robin($entry,$form){if (! $this->is_applicable_form($entry['form_id'])){return $entry}$rotation=$this->get_rotation_values($this->_args['field_id'],$form);$last_entry=$this->get_last_entry($entry,GFAPI::get_field($entry['form_id'],$this->_args['field_id']));// Get the value submitted for our designated field in the last entry.
$last_value=rgar($last_entry,$this->_args['field_id']);// Determine the next index at which to fetch our value.
$next_index=empty($last_value) ? 0 :array_search($last_value,$rotation)+1;if ($next_index>count($rotation)-1){$next_index=0}// Get the next value based on our rotation.
$next_value=$rotation[$next_index];// Update the value of our designated field in the database.
GFAPI::update_entry_field($entry['id'],$this->_args['field_id'],$next_value);// Update the value of our designated field in the $entry object that will be used to continuing processing the current submission.
$entry[$this->_args['field_id']]=$next_value;return $entry}public function get_last_entry($entry,$field){$field_filters=array();// GPPA integration only supports the first group of filters and filters that are field-specific (no custom values).
if (is_callable('gp_populate_anything') && $field->{'gppa-choices-enabled'}){$gppa_filters=rgar($field->{'gppa-choices-filter-groups'},0);foreach ($gppa_filters as $gppa_filter){if (strpos($gppa_filter['value'],'gf_field:') !==false){// Extract the field ID from the value property (e.g. `gf_field:3` → `3`).
$bits=explode('gf_field:',$gppa_filter['value']);$field_filters[]=array('key'=>$bits[1],'value'=>rgar($entry,$bits[1]),)}}}$last_entry=rgar(GFAPI::get_entries($entry['form_id'],array('status'=>'active','field_filters'=>$field_filters,),array('direction'=>'desc'),array('offset'=>1,'page_size'=>1,)),0);return $last_entry}public function add_round_robin_field_to_notification_email_fields($fields,$form){if (! $this->is_applicable_form($form)){return $fields}$field=GFAPI::get_field($form,$this->_args['field_id']);if (is_callable('gp_populate_anything') && $field->{'gppa-choices-enabled'}){$fields[]=$field}$rotation=$this->get_rotation_values($this->_args['field_id'],$form);if (filter_var($rotation[0],FILTER_VALIDATE_EMAIL)){$fields[]=$field}return $fields}public function get_rotation_values($field_id,$form){$field=clone GFAPI::get_field($form,$field_id);// Add support for GP Limit Choices.
if (is_callable('gp_limit_choices')){$field->choices=gp_limit_choices()->apply_choice_limits($field->choices,$field,$form)}// Add support for GP Inventory Choices.
if (is_callable('gp_inventory_type_choices')){$field->choices=gp_inventory_type_choices()->apply_choice_limits($field->choices,$field,$form)}$rotation=array_filter(wp_list_pluck($field->choices,'value'));return $rotation}public function is_applicable_form($form){$form_id=isset($form['id']) ? $form['id']: $form;return empty($this->_args['form_id']) || (int) $form_id===(int) $this->_args['form_id']}}# Configuration
new GW_Round_Robin(array('form_id'=>123,'field_id'=>4,));