WordPress.org

Ready to get started?Download WordPress

Forums

Gravity Forms - Update Post
Not working with Drop Down fields and custom taxonomies (15 posts)

  1. MarceFX
    Member
    Posted 2 years ago #

    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/

  2. rszczypka
    Member
    Posted 2 years ago #

    Thanks for the plugin. It's really great.
    However I'm experiencing the same problem with my custom post type taxonomies like MarceFX.

  3. MarceFX
    Member
    Posted 2 years ago #

    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;
      }
  4. MarceFX
    Member
    Posted 1 year ago #

    @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!

  5. rszczypka
    Member
    Posted 1 year ago #

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

  6. MarceFX
    Member
    Posted 1 year ago #

    @ 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

  7. rszczypka
    Member
    Posted 1 year ago #

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

  8. MarceFX
    Member
    Posted 1 year ago #

    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

  9. rszczypka
    Member
    Posted 1 year ago #

    @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'.

  10. MarceFX
    Member
    Posted 1 year ago #

    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!

  11. rszczypka
    Member
    Posted 1 year ago #

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

  12. MarceFX
    Member
    Posted 1 year ago #

    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!

  13. rszczypka
    Member
    Posted 1 year ago #

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

  14. srumery
    Member
    Posted 1 year ago #

    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!

  15. MarceFX
    Member
    Posted 1 year ago #

    @srumery, glad I could help :-)

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic