WordPress.org

Ready to get started?Download WordPress

Forums

Gravity Forms + Custom Post Types
Multi-selects only passing first value in custom taxonomy (4 posts)

  1. function5
    Member
    Posted 7 months ago #

    I am using GF + CPT in combination with CustomPress (from WPMUDEV). It works great overall but I am having a similar problem as discussed here: Multi-Selects Only Passing First Value to ACF. However, I am not using Advanced Custom Fields (ACF). Basically, the form submissions are saved correctly but the post is created with only the first value for each taxonomy passed.

    Please let me know how I should go about fixing this.

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

  2. jcow
    Member
    Posted 7 months ago #

    Having this problem as well.

    I fixed it by using checkboxes which are easier for users to use, so a real fix for multi select isn't pressing for me, but works as described by function5.

  3. sparkingproducts
    Member
    Posted 5 months ago #

    +1 for this, I'll be looking for a fix today and I'll keep you updated if I find one.

  4. sparkingproducts
    Member
    Posted 5 months ago #

    this is a pretty complicated fix, I'm sure someone could dumb this down but I hope this points the author of the plugin in the right spot if they ever try to tackle it.

    In the file gfcptaddonbase.php add this code on line 420. You will need to change the $entry['#'] to the number that equals your taxonomy's tag_ID. They match up in two spots, so in my code I have 34,35,36 and 37. Where it says 34 it needs to match in both spots.

    I have 4 taxonomies I'm using with this so it could be quite a bit shorter if you only have 1 or 2. Hopefully someone can take this and wrap it up a bit nicer

    } else if ( array_key_exists( 'type', $field ) && $field['type'] == 'multiselect' ) {            
    
    				$term_ids = array();
                    if (!$entry['34'] == '') {
    					$arr = $entry['34'];
    					$term_ids = explode(",",$arr);
    					foreach ($term_ids as $term_ints) {
    						$final[] = intval($term_ints);
    					}
    				   wp_set_object_terms( $entry['post_id'], $final, $taxonomy, true );
    				}
                    if (!$entry['35'] == '') {
    					$arr = $entry['35'];
    					$term_ids = explode(",",$arr);
    					foreach ($term_ids as $term_ints) {
    						$final[] = intval($term_ints);
    					}
    				   wp_set_object_terms( $entry['post_id'], $final, $taxonomy, true );
    				}
                    if (!$entry['36'] == '') {
    					$arr = $entry['36'];
    					$term_ids = explode(",",$arr);
    					foreach ($term_ids as $term_ints) {
    						$final[] = intval($term_ints);
    					}
    				   wp_set_object_terms( $entry['post_id'], $final, $taxonomy, true );
    				}
                    if (!$entry['37'] == '') {
    					$arr = $entry['37'];
    					$term_ids = explode(",",$arr);
    					foreach ($term_ids as $term_ints) {
    						$final[] = intval($term_ints);
    					}
    				   wp_set_object_terms( $entry['post_id'], $final, $taxonomy, true );
    				}

Reply

You must log in to post.

About this Plugin

About this Topic