Support

Account

Home Forums Backend Issues (wp-admin) WP Admin updates differently in DB than update_field() ? Reply To: WP Admin updates differently in DB than update_field() ?

  • Hi @chrisarter

    There’s no info on how your $cleanData looks like in your snippet but my guess is that you’re using the field names as key?

    Thing is that if you’re doing update_field for not previously existing values you have to use the field key rather than the field name. Otherwise the matching table value _fieldname with the field key as value aren’t created and because of that you’re going to have trouble using functions like get_field_object().

    The reason it’ll work after you manually hit update is because then ACF itself saves the values for the post with the field key present (so now you’ll have both values in your database).

    Just use the field keys instead and you’ll be good to go! These are hidden by default but can be turned on from the screen options in the top right corner.