Support

Account

Home Forums General Issues update_field + htmlentities problem

Solving

update_field + htmlentities problem

  • Hey guys, running into a problem with HTML Entities and update_field. I have a custom made front end form (simple text area) which does an ajax request and then calls some PHP on the backend that does an update_field() to a textarea field (Formatting set to “no Formatting”). This part of the process works fine.

    The field is for a custom post type I’m making, I very cleverly (or stupidly) made a wrapper class for the post type that does a get_fields() request to get all the values, and then when you call a save function in the class it goes through all the fields that are in an array and does update_field on them.

    The problem seems to be that somewhere during this save process htmlentities is being called on my field, even though its already had that done the first time, which results in a lot of garbage being displayed.

    Does anyone know where in the ACF code (or wordpress?) where it would be calling and how I can stop it? I’m happy to handle the htmlentities stuff myself.

    Cheers!

  • Hi Philip,

    WordPress sanitizes strings right down to the core. Checkout database insert in the following codex => http://codex.wordpress.org/Data_Validation

    What you are looking for is ‘Safe String’ functionality that I’m not sure WordPress has.

  • Hi @Phillip

    I think the htmlentities is being called on the field, because the value returned is being formatted by ACF.

    It is possible to ‘disable’ the ‘formatting’ using the get_field function (using a 3rd param of false – please see the docs for more info), however, this parameter is not available in the get_fields function.

    I’ll add this to the to-do for the next version, but for now, you might need to write a custom loop + get_field, instead of using get_fields.

    Thanks
    E

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

The topic ‘update_field + htmlentities problem’ is closed to new replies.