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.

Can conditional logic be used with after_submission hook?

  1. I am trying to implement the after_submission hook so that the form data goes to a third party database. I started by adding this code to the functions.php file: http://www.gravityhelp.com/documentation/page/Gform_after_submission

    Will that become the default location where all form data is sent? What happens to the conditional logic / notification settings?

    I would like route some data to the third party database, but some by email instead - is that possible? See form here (our site is in beta): http://collegesource.com.s127827.gridserver.com/contact-us

    In the drop down menu, if "u.achieve, u.direct, or u.select" option is selected different questions/form fields appear and that data I want to route via email only, which is already in place.

    I basically need help determining the hook to write & add to function.php file so that IF "u.achieve, u.direct, or u.select" selected send data to email listed in notifications settings ELSE use the after_submission hook to go to the third party DB.

    Does any of this make sense? Clearly I'm not a programmer but I am working with ours here to try to send form data to our in-house CMS for most submissions, but the one selection I mentioned above would go to email instead.

    Any help or detailed documentation is appreciated!

    Posted 12 years ago on Wednesday February 15, 2012 | Permalink
  2. Hi, alanna,

    This can be done by adding conditional logic in the notification. In the "Notification to Administrator" section, you can select "Routing". With Routing turned on you can setup conditions for your drop down, one for each of your selections you want to be sent as an email (u.achieve, u.direct, or u.select). For the drop down options you do not setup, an email will NOT be sent.

    Then you can use the "gform_after_submission" hook to handle the other drop down selections to send the data to a third party. You would use use this hook something like below:

    //add hook specific to form id = 45
    add_filter("gform_after_submission_45","send_to_third_party",10,2);
    function send_to_third_party($entry, $form)
    {
    	//checking the value for field 1
    	if (rgar($entry, "input_1") == "test1")
    	{
    		//send data to third party
    	}
    }

    The second example in the documentation at http://www.gravityhelp.com/documentation/page/Gform_after_submission points you to how you would pass the data along to a third-party's URL.

    Posted 12 years ago on Friday February 17, 2012 | Permalink

This topic has been resolved and has been closed to new replies.