Support

Account

Home Forums Front-end Issues get_field in field filter cause infinite loop Reply To: get_field in field filter cause infinite loop

  • Hey John,

    You are right, it could be like infinite loops in save_post hook. Thanks!

    https://codex.wordpress.org/Plugin_API/Action_Reference/save_post

    But using the get_post_meta() is easy enough, just wanted to make sure it was either a known issue or if it was a bug that could be addressed.

    Edit…
    Yes, that actually works. Remove and then reset the filter inside the filter when calling get_field().

    //sudo code

    add_filter('acf/load_field/key=field_55b1208a40b0e', 'form_load_field_55b1208a40b0e');
    function form_load_field_55b1208a40b0e ( $field )
    {
      remove_filter( 'acf/load_field/key=field_55b1208a40b0e', 'form_load_field_55b1208a40b0e' );
      $repeater_min_max = get_field( 'display_all_sites', $submission_post->ID );
      add_filter('acf/load_field/key=field_55b1208a40b0e', 'form_load_field_55b1208a40b0e');
    
      return $field;
    }