Support

Account

Home Forums Backend Issues (wp-admin) How to dynamically remove choices from select field? Reply To: How to dynamically remove choices from select field?

  • are ad_zones and field_59772109bf9d4 the same field? If they are then this is creating the infinite loop. You need to remove the filter at the beginning and add it again at the end so that the filter does not run when getting values from itself in other instances.

    
    function acf_load_ad_zones_choices( $field ) {
      remove_filter(acf/load_field/key=field_59772109bf9d4', 'acf_load_ad_zones_choices');
      
      // the rest of your function
      
      add_filter('acf/load_field/key=field_59772109bf9d4', 'acf_load_ad_zones_choices');
      
      return $field;
    }