WordPress.org

Ready to get started?Download WordPress

Forums

Gravity Forms + Custom Post Types
Multi-Select field does not save all taxonomies (7 posts)

  1. WebEndev
    Member
    Posted 2 years ago #

    The problem that I am having is identical to this previous thread.

    When using the Multi Select field, and selecting more than one value, only the first one selected is passed back to the post custom taxonomy.
    My custom taxonomy (genre) is attached to a custom post type(book).
    I am using a checkbox field as a workaround, and this works fine.

    Using version 3.0.1 of the plugin.

    Thanks!

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

  2. snails07
    Member
    Posted 2 years ago #

    I’m having the same issue with the multi-select and taxonomies.
    Also using version 3.0.1
    Any idea when this will be updated?

    Thanks

  3. bradvin
    Member
    Plugin Author

    Posted 2 years ago #

    hey guys,

    This has been fixed in V4 beta, but it is not released yet, as I am still testing it. Please check out the new features and test it to see that it works for you.

    http://themergency.com/gravity-forms-custom-post-types-v4-beta-testers-wanted/

    cheers

  4. Jay Collier
    Member
    Posted 2 years ago #

    For what it's worth, here is what our developer wrote about the problem:

    CPT addon doesn't properly account for multiselect boxes. GF turns
    multiselect values into a comma-separated string, which it was then
    casting as an integer, with the result that something like '3,10,12'
    would become simply '3'. Thus only the first field was being saved to
    the post.

    Here is the patch we applied until V4 is ready:

    diff --git a/wp-content/plugins/gravity-forms-custom-post-types/gfcptaddonbase.php b/wp-content/plugins/gravity-forms-custom-post-types/gfcptaddonbase.php
    index 9748d14..4359244 100644
    --- a/wp-content/plugins/gravity-forms-custom-post-types/gfcptaddonbase.php
    +++ b/wp-content/plugins/gravity-forms-custom-post-types/gfcptaddonbase.php
    @@ -413,6 +413,10 @@ function save_taxonomy_field( &$field, $entry, $taxonomy ) {
                   $terms = $entry[$field['id']];
                   if ( !empty($terms) )
                     wp_set_post_terms( $entry['post_id'], $terms, $taxonomy );
    +            } else if ( array_key_exists( 'type', $field ) && $field['type'] == 'multiselect' ) {
    +              // terms are passed as comma-separated
    +              $term_ids = wp_parse_id_list( $entry[$field['id']] );
    +              wp_set_object_terms( $entry['post_id'], $term_ids, $taxonomy, true );
                 } else {
                     $term_id = (int) $entry[$field['id']];
                     if ( $term_id > 0 )

    Thanks so much, Brad, for your continuing support for this essential plugin!

  5. minute14
    Member
    Posted 1 year ago #

    I just downloaded and installed v4 beta and the issue with multiple selections not posting still exists. I would like to add the above code to resolve it. Where and what file i would need to add it? functions.php in my theme?

    Thanks again for the great plugin! :)

  6. minute14
    Member
    Posted 1 year ago #

    I just deleted the beta version and reinstalled the currentone.

    Where does the above code go? gfcptaddonbase.php?

    Thanks again :)

  7. bradvin
    Member
    Plugin Author

    Posted 1 year ago #

    Hi there

    I just checked the code in V4 beta and it does something very similar to the code posted above, so it does save multiple taxonomies. What type of field are you using?

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic