Home Forums Front-end Issues Repeater in acf_form wont update


Repeater in acf_form wont update

  • Im having problems with my acf_form() front end form which works as expected, but only wont save my text values inside a repeater. Its a simple repeater with only 1 text field.
    When looking at $_POST it contains the repeater array with the right values, but the fields are not being updated.
    I have an hook on the acf/save_post action, but im not touching the repeater in there and all other fields update nicely. The acf/save_post hook function is just setting a random unique value for all posts:

    function add_unique_post_identifier( $post_id ) {
      if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE)
          return $post_id;
      // do nothing if post type is not 'post' or identifier is already set
      if ( 'event' !== get_post_type( $post_id ) || get_field('field_565c23fe27c37', $post_id) || empty($_POST['acf']) )
          return $post_id;
      $generated_id = uniqid();
      update_field('field_565c23fe27c37', $generated_id, $post_id);
      //wp_mail() function
    add_action( 'acf/save_post', 'add_unique_post_identifier', 20 );

    Updating the repeater in wordpress backend works fine.

  • I’ve given this a quick test on a site with only acf installed and the repeater is saving.

    I don’t see anything in that filter that should be causing a problem, but have you tried disabling it to test, just in case?

    If that doesn’t do it then deactivating other plugins and maybe switching themes to a default 20XX theme might help narrow down where the problem is.

  • Yes I’ve tried disabling the filter.
    Its my own theme that Im developing and I’ve tried disabling major functions and actions + deactivating all plugins..
    Cant see anything suspicious in the database.
    Any other ideas on how I could narrow down the issue?

    Best regards.

  • What’s the name of the repeater field? is it unique?

  • Ive tried changing it a few times in the past, thought the same thing.
    Its called ‘event_times’.
    The 2 text fields are called ‘event_from_time’ and ‘event_to_time’ – which seems legit enough?

  • There only things that I can think of that would cause this are

    1) you have another field on the same form with the same field name
    2) you have filter somewhere on the site that is interfering
    3) you’re using a field that’s not somehow not attached to the post type

    What do the code and arguments for acf_form() look like? Can you post that?

  • How could i get an indication whether my field is attached to the right post type?

    My acf_form looks like this:

    add_filter('acf/update_value', 'wp_kses_post', 10, 1);
    get_header(); ?>
    	'post_id'	=> 'new_post',
    	'submit_value'  => __("Submit", 'acf'),
    	'post_title'    => true,
    	'field_groups'	=> array(74, 1019),
    	'new_post'	=> array(
    		'post_type'	=> 'events',
    		'post_status'	=> 'pending'
    	'tax_input'	=> array( 'photo_category' => array( date('Y') ) ),
    	'uploader' 	=> 'basic'

    Also im using this filter for a custom title label:

    add_filter( 'acf/get_valid_field', 'change_input_labels');
    function change_input_labels($field) {
    	if($field['name'] == '_post_title') {
    		$field['label'] = 'Name';
    	return $field;
  • Oops, by the way, its two select fields i have in the repeater, not text fields.

    It seems there is an issue between your acf_form and the wp_kses_post() sanitize function.
    I just tried the same setup on another wp installation where i was able to do some more debugging and found a header conflict.
    So i tried removing the sanitization function and then my select fields update fine.

  • Aha, I now realise that the whole messed is based on my use of select fields and not text fields with the wp_kses_post() function.
    Many have had this issue to fight with it looks like.
    I will now try to use your function:

    function acf_wp_kses_post($data) {
      if (!is_array($data)) {
        return wp_kses_post($data);
      $return = array();
      foreach ($data as $index => $value) {
        $return[$index] = acf_wp_kses_post($value);
      return $return;
  • Glad you got it worked out. Yes, using wp_kses_post on either a repeater or a multiselect field would cause the field values to be destroyed.

  • Thanks John,
    But as the other fellas pointed out, this would be useful information on the acf_form doc page.

  • I agree, it would be useful to mention on the acf_form page, but other than E I don’t think anyone can update the documentation. The documentation is a bit behind in several places as others have mentioned.

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

The topic ‘Repeater in acf_form wont update’ is closed to new replies.