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;
}
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.