Support

Account

Forum Replies Created

  • Victory!

    Your comment on when we were calling update_field turned out to be right on the money. Interestingly, it was initialized enough to be able to run update_field on regular Text/Number fields, but not enough to allow Repeater fields to be updated.

    So, we added an add_action which ensured that our plugin fired after all others had, like so:

    add_action('plugins_loaded', 'name_of_function');

    This solved the issue! Thank you SO much for all of your help and responsiveness, it is VERY much appreciated! We owe you big time!

  • We’ve also tried your code snippet (outside of any function) in functions.php, and it works just fine there as well.

    We’re trying to now call the update_field functionality from functions.php itself by putting it within its own function, that we could then call outside of it. Something like this would go in functions.php:

    function update_repeater_field($field_to_update, $value, $post) {
      update_field($field_to_update, $value, $post);
      echo "function update_repeater_field triggered.<br/><br/>";
    }
    add_action('acf/init', 'update_repeater_field', 10);

    And then we would call update_repeater_field($field_to_update, $value, $post); from our plugin. No success yet, the plugin sees the function as undefined, but theoretically that functionality should work, correct?

    Thanks again for your continued help!

  • Some progress to report – I tried moving your example completely out of our plugin and dropped it into a WordPress template, and that successfully updated the repeater!

    So, we now know it’s something about calling that code from within the plugin that is causing repeater updates not to function (but allowing Text and Number fields to be updated without issue, for some reason).

    I tried identifying the post ID manually from within the plugin, like so:

    $repeater_key = 'field_6050d513a3996';
    $value =  array(
    	array(
    		'field_6050d550a3997' => '(123)456-7890',
    		'field_6050d596a3998' => 'description sent from plugin'
    	)
    );
    
    update_field($repeater_key, $value, 48058);

    Sadly, this did not work either – but we’re making progress!

    So the question now becomes: Is there anything that could possibly block repeater (or perhaps just nested?) updates from happening when done within a plugin?

  • That’s a possibility – we’ll start investigating that. Thanks for the lead, I will keep you posted! And thanks again for your quick response!

  • Thanks so much for the quick response John! I’ve tried it with your code snippet, updating the repeater directly, but unfortunately the repeater still does not update. I’ve double-checked the field keys to ensure they are correct, and re-confirmed that other Text and Number fields update without issue.

    I’ve attached a screenshot of how we have the repeater configured in ACF, just in case there’s something there that might be stopping this from working.

    Phone Numbers repeater setup in ACF

    Thanks again so much for your help!

Viewing 5 posts - 1 through 5 (of 5 total)