WordPress.org

Support

Support » Plugins and Hacks » Gravity Forms - Update Post » [Plugin: Gravity Forms – Update Post] Not working with Drop Down fields and custom taxonomies

[Plugin: Gravity Forms – Update Post] Not working with Drop Down fields and custom taxonomies

  • Hi,

    I’m using Gravity Forms with Woocommerce. I have a custom Drop Down Field which populates with a taxonomy. The problem is that every time that the post is updated and the taxonomy is changed, this new value sums up to the old one.

    Instead of “replacing” the value of the taxonomy in the Drop Down field, the plugin adds a new value, ending up with as many values as times the post and taxonomy are updated.

    Any fix for this?

    Thanks

    http://wordpress.org/extend/plugins/gravity-forms-update-post/

Viewing 14 replies - 1 through 14 (of 14 total)
  • Thanks for the plugin. It’s really great.
    However I’m experiencing the same problem with my custom post type taxonomies like MarceFX.

    I have tried using this function (included in gravityforms-update-post.php), but it’s not working. I replaced “post_custom_field” for “select”, since I think that’s the Drop Down field name. I also delete the “isset” condition in order to always apply the function, but no luck…

    Any ideas?

    public function gform_post_data($post_data, $form)
      {
        if ($this->is_allowed() && !$this->is_delete())
        {
          // If a custom field is unique, delete the old value before we proceed
          foreach ($form['fields'] as $field)
          {
            if ($field['type'] == 'post_custom_field' && isset($field['postCustomFieldUnique']))
            {
              delete_post_meta($this->post['ID'], $field['postCustomFieldName']);
            }
          }
    
          $post_data['ID'] = $this->post['ID'];
          $post_data['post_type'] = $this->post['object']['post_type'];
    
          $this->options['post_status'] = apply_filters($this->name . '_status', $this->options['post_status'], $form);
    
          if (in_array($this->options['post_status'], array('draft', 'publish', 'pending', 'future', 'private', 'inherit')))
          {
            $post_data['post_status'] = $this->options['post_status'] == 'inherit' ? $this->post['object']['post_status'] : $this->options['post_status'];
          }
        }
    
        return $post_data;
      }

    @rszczypka, I hired someone to do the job. Since it’s a simple change, I’m sharing it here 😉

    I guess you’re using the Graviy Forms Custom Post plugin:

    1. Open gfcptaddonbase.php

    2. Go to line 419:
    wp_set_object_terms( $entry['post_id'], $term_id, $taxonomy, true );

    3. Change “true” to “false”.

    Let me know if it works.

    Cheers!

    @marcefx, works like a charm! Thanks a lot for sharing it with the rest of us!

    @ rszczypka, sorry but I just found thought a tiny little issue. If you have subattributes, they don’t show on the Gravity Forms dropdown. They are linked to the actual post, but there’s something wrong with that…

    I’m trying to fix it. If you find anything that can help, let me know.

    Thanks

    @marcefx, what do you mean by subattributes? a child taxonomy?

    Ouch, yes, sorry. I didn’t know the english for that one… haha. Are you using them? Can you please try and see if that happens to you too?

    Thanks

    @marcefx, sorry, I can’t see any issues with it. Before I was using only parent categories. Now I added a new category and chose a parent for it and in the frontend the dropdown displays it correctly, I can choose the new category and it saves it.
    I’m using Drop Down field with the option ‘Populate with a Taxonomy’.

    Weird thing. The developer who modified the plugin in the first placed just fixed it for me. He said it was a bug from GF. Anyway, thanks for testing.

    Cheers!

    What version of GF do you have? I have 1.6.7.

    That’s the problem. I have 1.6.4.5.4. We can’t update since our site would break down… We have done tons of custom work on it :-/

    Cheers!

    I see. I know the pain. Cheers. Good luck!

    MarceFX – Thank you for the fix! Setting the append attribute to false in gfcptaddonbase.php did the trick.

    rszczypka – Thank you for testing and verifying.

    Cheers to you both!

    @srumery, glad I could help 🙂

Viewing 14 replies - 1 through 14 (of 14 total)
  • The topic ‘[Plugin: Gravity Forms – Update Post] Not working with Drop Down fields and custom taxonomies’ is closed to new replies.
Skip to toolbar