Awesome plugin, but it appears that updating custom fields is only working intermittently.
The title and body are working fine and update every time but the custom fields rarely update.
I also have the Gravity Forms + Custom Post Types plugin installed and the custom taxonomies never update.
I’m using tons of custom taxonomies with my posts which are a custom post type and I haven’t seen any issues. Then again maybe I haven’t tested it enough. I’ll bang on my forms a bit and see if I can reproduce the issue you are seeing. What version of WordPress and Gravity Forms are you using?
Using the latest version of both. WordPress version 3.3.2 and the Update Post plugin version 0.5.2
So I was mistaken. It turns out that I am seeing the same exact problem. I’ll spare the details as to why I didn’t recognize the behavior the first time around but here’s what I’m seeing now:
I’m using a post form with custom post fields to insert data into several wp_postmeta fields. I have a separate form that I use to edit the post, including the custom post fields. When I update the post, with the edit form, the custom post fields create new meta-key/meta-value fields in wp_postmeta instead of editing the existing meta-key/meta-value data. That’s actually kind of what I would expect given the nature of the wp_postmeta table.
So I changed my post form as follows. On each of the custom post fields I checked the “Unique Custom Field” checkbox. I did not make any changes to the edit post form. When I add a post with the post form everything works fine. If I edit the post the original meta-values in the wp_postmeta table are modified instead of having new meta-key/meta-value pairs added. It should be problem solved but unfortunately, editing the post adds a bunch of unexpected data to the meta-value which totally breaks everything (my browser can’t even render the post afterwards). Here’s an example of the meta-key and meta-value before and after an edit:
If I modify the edit post form and set all of the custom post fields to “Unique Custom Field”, I still see the same effect. I have yet to determine why this happens but I’m still testing various configurations.
Ok, so I got it worked out. You have to set custom fields to “Unique Custom Fields” in the Gravity Forms Form Editor if you want to be able edit fields with this plugin. In addition, you have to change this line in the Gravity Forms – Update Post plugin code:
$meta = get_post_meta($this->post['ID'], $field['postCustomFieldName']);
$meta = get_post_meta($this->post['ID'], $field['postCustomFieldName'], true);
This line can be found under the comment “// If a custom field is unique, get all the rows and combine them into one”
Thanks to dskvr for originally posting this fix here:
I was actually working on this bug over the weekend and I have submitted an update. The patch noted above is close but only fetches one meta value, even if there are multiple rows could be in the database. Let me know if anyone has problems with the update, I will check in on this thread frequently.
Thanks Kevin, the custom fields all seem to be working now.
The custom taxonomies aren’t working properly though. I have checkboxes set up for my custom taxonomies and if I check one it saves okay, and then I edit the post again and check another taxonomy and this saves. But when I uncheck a taxonomy and update the post, it still stays checked.
So it works fine to add a taxonomy but not to remove one.
Wanted to hop on the update bandwagon as I have extended this plugin for a client to allow for updating gravity forms field type “list”.
I was working off version 0.5.2 so I have included a diff to show what I did. If you need me to integrate these with v0.5.3 let me know. I should have some time later this week.
Did you ever port that fix over to v0.5.3?
I’m wondering if there is a way to store lists as custom post meta and return that post meta as a list. Specifically lists with multiple columns.
No I didn’t but you can get the code from the gist link I put in there.
As for a way to store lists as a single custom post meta you would have to write custom code to get all list items before they are saved to the database and serialize them and store that as a custom post meta, then unserialize it when you retrieve it.
Thought not sure why you would need to do this as the way lists are saved now work fine in terms of storing and pulling.
- The topic ‘[Plugin: Gravity Forms – Update Post] Custom fields not really working’ is closed to new replies.