Support

Account

Home Forums General Issues Update ACF Checkbox field option spelling

Solved

Update ACF Checkbox field option spelling

  • What’s the best way of updating the spelling of an option on a ACF Checkbox field (saved to users) without removing any users that have already selected that option? From my testing, when you change the spelling of the option, the users that had chosed the misspelt option no longer have it selected, which makes sense. Do I need to do a find and replace on the database to reattach the updated option? Not sure if that makes sense!

  • This is what I would do.

    First I would add the new value without removing the old value

    Then I would add an acf/load_value filter for the field. In this filter I would loop over the values that are already set and replace the old value if it exists with the new value.

    Then I would delete the old value from the field.

    At this point I would ignore it. When the user updates the new value will be set and until then the old value will be replace with the new value.

    On the other hand if I set up it us using value and labels in the field settings like this

    
    value 1 : label 1
    value 2 : label 2
    

    I would change the label end ignore the incorrect spelling on the value

  • Thanks for your response @hube2 !

    In the acf/load_value filter, would I loop through all the users using a WP_User_Query? I’m not quite sure how I would check if the user has the old value selected to then replace with the new value.

    Do I need to rely on each user clicking update on the front end form for the changes (selection of the new value) to come into effect?

  • @hube2 I came up with an alternate solution using a Search and Replace plugin (Better Search Replace by Delicious Brains who now owns ACF of course!)

    I did a search and replace on the wp_usermeta table for the typo and replaced it with the correct spelling. I then went into the checkbox field setting and fixed the typo. After that I checked any users who had the typo selected and their choice had updated (and remained checked)!

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

You must be logged in to reply to this topic.