Support

Account

Home Forums Bug Reports Fields are randomly not saved

Solved

Fields are randomly not saved

  • Cross post from wordpress support page

    In a shop I am working on, I created a few custom fields associated to the product post type. I have a strange issue that cannot debug further. When I publish or update the product, some of the custom fields stay empty (not updating).

    What I did for debugging:

    – Disabled all the plugins except Woocommerce and ACF
    – Changed theme to storefront
    – Disable server and website cache
    – Check server logs (nothing there)
    – Enable wp_debug and also nothing
    – Disable every custom code I had in the child theme

    What I also found:

    – The name doesn’t matter. I created a field called “Box Quantity” and I couldn’t save it. Then I delete all the custom fields and create just this one and it worked. Adding more kept this one working but not the new fields
    – Checked the database on the postmeta table and the fields values are not there. So not saved at all.

    Those are some of the server settings that might affected it. As you see, values are big enough and I even tried to increase them more with no success.

    
    PHP version	7.2.34
    PHP max input variables	6500
    PHP time limit	3600
    PHP memory limit	3072M
    Max input time	1000
    PHP post max size	260M
    WordPress Version 5.8.2
    Advanced Custom Fields Version 5.11.4
    WooCommerce Version 6.0.0
    
  • The only thing that I have seen that can cause this is PHP max_input_vars. Your value seems large enough, but I don’t know. Please try installing this plugin and then seeing if it gives an alert. I know the plugin says is has not been updated in a while but it still works. https://wordpress.org/plugins/wp-max-submit-protect/

  • Unfortunately, it didn’t work. Unless I need to do something more than installing the plugin. I updated my question in the wordpress forum, with this. Might be helpful?

    Trying to debug further. When I click on update on the post, if I inspect the HTTP request to admin-ajax.php, the payload has this:

    acf[field_61cf02821292a]: 500
    acf[quantity-label]: 1000 items

    The first one is saved to the database, while the second doesn’t. Doing more tests, looks like all the acf that have the name field_xxxx in the payload gets the update, while the rest don’t

    I am not 100% sure, but I think, the first field on the group I create takes the correct key format and every other custom field in that group takes the name of the field as the key. Which makes it not getting updated.

  • I don’t know why you’re getting this:

    
    acf[quantity-label]: 1000 items
    

    ACF inputs should always be the field key, not the field name

  • Even if I create new fields now, in a new group, I still get keys like this one. I can verify it by going to Tools and then Export. I read that all keys should be in field_xxxx format, but no idea why it’s happening for me. As I said, I disabled all themes and plugins and was able to reproduce.

  • The most likely cause of this is a filter or plugin that is modifying post_name (slug) when posts are saved.

  • Oh damn. You are so clever!!! That was it. It was part of my code where I update the post slug based on the post title. I removed that code and tested the post update/publish part only, when acf have already been created. Thank you so much! Saved me a lot of time!

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

You must be logged in to reply to this topic.