Support

Account

Home Forums Bug Reports add_filter(acf/update_value, wp_kses_post) in acf_form() breaks select fields

Solved

add_filter(acf/update_value, wp_kses_post) in acf_form() breaks select fields

  • I tried the

    add_filter('acf/update_value', 'wp_kses_post', 10, 1);

    filter on a repeater with select options, and on save, the select options will not save. Not sure if this is a bug w/ ACF or wp_kres_post, just figured I’d say something so that maybe a warning that not all form fields are compatible with that filter can go on the acf_form() page.

  • ACF stores some values, like multi-select and checkbox fields as well as some others as serialized arrays. Running wp_kses_post on these values after ACF has serialized them removes the formatting needed to unserialize them. Running it on arrays before they have been serialized converts them to a strings.

    If you want to run this on these types of fields you’d need to run it on each element of the array rather than the array itself before itis serialized. You’ll probably need to create a specific filter to do it.

    If you want to run this on text, textarea and other fields that allow arbitrary input you should target these fields with the field type involved

    add_fitler('acf/update_value/type=text, ‘wp_kses_post’);`

  • I was also having trouble with this. All of the fields in repeaters were converting to “A”, and it was hard to tell why. I think there should be a note of this made on the documentation for acf_form.

  • I’ve added some more guidance on this thread.

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

The topic ‘add_filter(acf/update_value, wp_kses_post) in acf_form() breaks select fields’ is closed to new replies.