PLEASE NOTE: These forums are no longer utilized and are provided as an archive for informational purposes only. All support issues will be handled via email using our support ticket system. For more detailed information on this change, please see this blog post.

gform_after_submission & conditional logic fields

  1. minimay
    Member

    Hi, I have a contact form on my site that uses conditional logic to display one of many state county dropdowns depending on what state the user selects in a state pulldown. We need to pass this data to a third party site and I'm using the gform_after_submission function, which works great. But I'm not sure how to add all these county fields to the function, where my variable "county" could equal $entry[9], $entry[10], or all the way up to $entry[59]! Can someone help me figure out how to format this variable in the function? I thought it might be with an array but that doesn't work. I just don't know how to assemble everything, here's my code that isn't working-- I see the $county array when I print_r the fields, but it's not passing to the third party site. (I've changed the $post_url here for privacy)

    function post_to_third_party($entry, $form) {
    		$post_url = 'Our Third Party Site';
    		$county = array($entry['9'],$entry['10'],$entry['11'],$entry['12'],$entry['13'],$entry['14']);
    		$body = array(
    			'namefirst' => $entry['1'],
    			'namelast' => $entry['2'],
    			'zip' => $entry['3'],
    			'email' => $entry['4'],
    			'phone' => $entry['5'],
    			'loanamt' => $entry['6'],
    			'propvalue' => $entry['7'],
    			'state' => $entry['8'],
    			'county' => $county
    			);
    		$request = new WP_Http();
    		$response = $request->post($post_url, array('body' => $body));
    		print_r($post_url);
    	}
    Posted 6 years ago on Thursday June 20, 2013 | Permalink
  2. David Peralty
    Administrator

    I've asked the developers to comment on this.

    Posted 6 years ago on Thursday June 20, 2013 | Permalink
  3. minimay
    Member

    I've found a very wonky workaround, I am so bad at arrays... I deleted the array items that were empty (using array_filter) and then isolated the selected array value using array_shift and then passed it to the entry in the $post_url $body. That did the trick but I'm sure this can be accomplished much more eloquently.

    Thank you for making Gravity Forms so awesome!

    Posted 6 years ago on Friday June 21, 2013 | Permalink