<?xml version="1.0" encoding="UTF-8"?>
<!-- generator="bbPress/1.0.1" -->
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title>Gravity Support Forums Topic: Custom Routing Based On Form Fields</title>
		<link>https://legacy.forums.gravityhelp.com/topic/custom-routing-based-on-form-fields</link>
		<description>Gravity Support Forums Topic: Custom Routing Based On Form Fields</description>
		<language>en-US</language>
		<pubDate>Sun, 19 Apr 2026 18:24:49 +0000</pubDate>
		<generator>http://bbpress.org/?v=1.0.1</generator>
		<textInput>
			<title><![CDATA[Search]]></title>
			<description><![CDATA[Search all topics from these forums.]]></description>
			<name>q</name>
			<link>https://legacy.forums.gravityhelp.com/search.php</link>
		</textInput>
		<atom:link href="https://legacy.forums.gravityhelp.com/rss/topic/custom-routing-based-on-form-fields" rel="self" type="application/rss+xml" />

		<item>
			<title>nology on "Custom Routing Based On Form Fields"</title>
			<link>https://legacy.forums.gravityhelp.com/topic/custom-routing-based-on-form-fields#post-293172</link>
			<pubDate>Fri, 31 May 2013 16:46:08 +0000</pubDate>
			<dc:creator>nology</dc:creator>
			<guid isPermaLink="false">293172@https://legacy.forums.gravityhelp.com/</guid>
			<description>&#60;p&#62;Dave, thanks for all the help. I got it working. I had to change the name of my email notification from Admin Notification to my Admin Email (which is what I named mine)&#60;/p&#62;
&#60;p&#62;Here is the working version if anyone else happens to be using the address field and needs to use routing based on the address.state field...&#60;/p&#62;
&#60;pre&#62;&#60;code&#62;add_filter(&#38;quot;gform_notification_2&#38;quot;, &#38;quot;route_notification&#38;quot;, 10, 3);

function route_notification($notification, $form, $entry) {

global $post;
global $fromstate;
global $tostate;

	if($notification[&#38;quot;name&#38;quot;] == &#38;quot;Admin Email&#38;quot;){ // The name of my admin notification 

	$notification[&#38;#39;toType&#38;#39;] = &#38;quot;email&#38;quot;;
	$fromstate = $_POST[&#38;quot;input_4_4&#38;quot;]; //my form field id
	$tostate = $_POST[&#38;quot;input_12_4&#38;quot;] ; //my form field id

			if ($fromstate == &#38;quot;Illinois&#38;quot; &#124;&#124; $tostate == &#38;quot;Illinois&#38;quot;) { // Here I am checking for two fields and if they = Illinois
					$notification[&#38;#39;to&#38;#39;] = &#38;quot;emailtwo@email.com&#38;quot;; //If illinois send to the iaddress
				} else {
					$notification[&#38;#39;to&#38;#39;] = &#38;quot;emailtwo@email.com&#38;quot;; // If no illinois send to this address
			}
	}

return $notification;
}&#60;/code&#62;&#60;/pre&#62;
&#60;p&#62;Would be cool to add these fields to the built in conditional logic.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>nology on "Custom Routing Based On Form Fields"</title>
			<link>https://legacy.forums.gravityhelp.com/topic/custom-routing-based-on-form-fields#post-293148</link>
			<pubDate>Fri, 31 May 2013 16:23:09 +0000</pubDate>
			<dc:creator>nology</dc:creator>
			<guid isPermaLink="false">293148@https://legacy.forums.gravityhelp.com/</guid>
			<description>&#60;p&#62;No luck. I tried the following formats...&#60;/p&#62;
&#60;p&#62;input_4_4&#60;br /&#62;
input_12_4&#60;/p&#62;
&#60;p&#62;input_2_4_4&#60;br /&#62;
input_2_12_4&#60;/p&#62;
&#60;p&#62;I was also incorrect. The email I get is the default email when you setup an admin notification. So, no matter what logic I apply, it always send to the notification address setup in the notifications. So... neither of these two email I have in my code get triggered.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>David Peralty on "Custom Routing Based On Form Fields"</title>
			<link>https://legacy.forums.gravityhelp.com/topic/custom-routing-based-on-form-fields#post-293054</link>
			<pubDate>Fri, 31 May 2013 15:07:59 +0000</pubDate>
			<dc:creator>David Peralty</dc:creator>
			<guid isPermaLink="false">293054@https://legacy.forums.gravityhelp.com/</guid>
			<description>&#60;p&#62;I think when they are posted the fields become input_4_4 instead of input_4.4. Try that and let me know.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>nology on "Custom Routing Based On Form Fields"</title>
			<link>https://legacy.forums.gravityhelp.com/topic/custom-routing-based-on-form-fields#post-293050</link>
			<pubDate>Fri, 31 May 2013 15:01:13 +0000</pubDate>
			<dc:creator>nology</dc:creator>
			<guid isPermaLink="false">293050@https://legacy.forums.gravityhelp.com/</guid>
			<description>&#60;p&#62;Hi David,&#60;/p&#62;
&#60;p&#62;Thanks for the reply. I would love to use the built in conditional logic on notifications but it does not look like address fields are selectable as part of the list of selectable form fields. All my other fields show up but the ones in an address field (address, city, state, zip).&#60;/p&#62;
&#60;p&#62;I am trying to target the address.state field for the from and to addresses. I know I can create these fields individually and not use an address field, but need to use the address fields as they need to sit side by side and is part of a multi page form.&#60;/p&#62;
&#60;p&#62;So.. I am trying to do this via code instead.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>David Peralty on "Custom Routing Based On Form Fields"</title>
			<link>https://legacy.forums.gravityhelp.com/topic/custom-routing-based-on-form-fields#post-292946</link>
			<pubDate>Fri, 31 May 2013 13:44:50 +0000</pubDate>
			<dc:creator>David Peralty</dc:creator>
			<guid isPermaLink="false">292946@https://legacy.forums.gravityhelp.com/</guid>
			<description>&#60;p&#62;Is there any reason why you aren't using Conditional Logic in our Notifications system to do this? You could have a Notification that says: Send this email if all the following are true:&#60;br /&#62;
if user selects Illinois in statefrom&#60;br /&#62;
If user selects Illinois in stateto
&#60;/p&#62;</description>
		</item>
		<item>
			<title>nology on "Custom Routing Based On Form Fields"</title>
			<link>https://legacy.forums.gravityhelp.com/topic/custom-routing-based-on-form-fields#post-292853</link>
			<pubDate>Fri, 31 May 2013 12:57:47 +0000</pubDate>
			<dc:creator>nology</dc:creator>
			<guid isPermaLink="false">292853@https://legacy.forums.gravityhelp.com/</guid>
			<description>&#60;p&#62;OK.. so I had some issues with the filter (had a mix of deprecated and new code). However, I am still not there yet. Everything seems to be working but the ability to check field values for the from and to state. It appears I am unable to get the form post values. So my IF statement always fires off &#60;a href=&#34;mailto:emailtwo@email.com&#34;&#62;emailtwo@email.com&#60;/a&#62;.&#60;/p&#62;
&#60;p&#62;So here is what I have at the moment. Any thoughts on how I can get the field values so I can check the $fromstate and to $tostate?&#60;/p&#62;
&#60;pre&#62;&#60;code&#62;add_filter(&#38;quot;gform_notification_2&#38;quot;, &#38;quot;route_notification&#38;quot;, 10, 3);

function route_notification($notification, $form, $entry) {

global $post;
global $fromstate;
global $tostate;

	if($notification[&#38;quot;name&#38;quot;] == &#38;quot;Admin Notification&#38;quot;){

	$notification[&#38;#39;toType&#38;#39;] = &#38;quot;email&#38;quot;;
	$fromstate = $_POST[&#38;quot;input_4.4&#38;quot;];
	$tostate = $_POST[&#38;quot;input_12.4&#38;quot;] ;

			if ($fromstate = &#38;quot;Illinois&#38;quot; &#124;&#124; $tostate = &#38;quot;Illinois&#38;quot;) {
					$notification[&#38;#39;to&#38;#39;] = &#38;quot;emailone@email.com&#38;quot;;
				} else {
					$notification[&#38;#39;to&#38;#39;] = &#38;quot;emailtwo@email.com&#38;quot;;
			}
	}

return $notification;
}&#60;/code&#62;&#60;/pre&#62;</description>
		</item>
		<item>
			<title>nology on "Custom Routing Based On Form Fields"</title>
			<link>https://legacy.forums.gravityhelp.com/topic/custom-routing-based-on-form-fields#post-290286</link>
			<pubDate>Thu, 30 May 2013 16:34:38 +0000</pubDate>
			<dc:creator>nology</dc:creator>
			<guid isPermaLink="false">290286@https://legacy.forums.gravityhelp.com/</guid>
			<description>&#60;p&#62;Hello,&#60;/p&#62;
&#60;p&#62;Having a bit of trouble trying to get custom routing working. I get no errors, but I also do not get the email notifications.&#60;/p&#62;
&#60;p&#62;I have two address fields and I need to get the state from each. If neither of these fields are Illinois, it should route to &#60;a href=&#34;mailto:emailone@email.com&#34;&#62;emailone@email.com&#60;/a&#62; else send to &#60;a href=&#34;mailto:emailtwo@email.com&#34;&#62;emailtwo@email.com&#60;/a&#62;.&#60;/p&#62;
&#60;p&#62;Here is my filter and function:&#60;/p&#62;
&#60;pre&#62;&#60;code&#62;add_filter(&#38;quot;gform_notification_2&#38;quot;, &#38;quot;route_notification&#38;quot;, 10, 3);
// gform_notification_2 is form ID 2&#60;/code&#62;&#60;/pre&#62;
&#60;pre&#62;&#60;code&#62;function route_notification($email_to, $entry) {
global $post;
$fromstate = $entry[&#38;quot;4.4&#38;quot;]; //the first number (4) is address field id, the second number is the state field id in the address field.
$tostate = $entry[&#38;quot;12.4&#38;quot;] ; //the first number (12) is address field id, the second number is the state field id in the address field. 

if ($fromstate != &#38;quot;Illinois&#38;quot; &#124;&#124; $tostate != &#38;quot;Illinois&#38;quot;) {
		$email_to = &#38;#39;emailone@email.com&#38;#39;;
	} else {
		$email_to = &#38;#39;emailtwo@email.com&#38;#39;;
}
	return $email_to;
}&#60;/code&#62;&#60;/pre&#62;
&#60;p&#62;Any assistance would be greatly appreciated. I think my main concern/issue is that I may not be getting field values correctly.
&#60;/p&#62;</description>
		</item>

	</channel>
</rss>
