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.

Conditional notification mesasage

  1. Hello

    Is it possible to send a different message based on an action within the form? So for example I have a drop-down, if a user selects option 1, they get email notification message 1, if they select option 2, they get message 2.

    Any suggestions as to how this might be achieved?

    Many thanks

    Posted 14 years ago on Wednesday July 28, 2010 | Permalink
  2. binarylab
    Member

    I'm looking for this functionality too!

    Posted 14 years ago on Wednesday July 28, 2010 | Permalink
  3. Conditional email notifications aren't currently possible. We are planning on developing an advanced notification add-on that will add this type of functionality, but currently it isn't possible.

    It is possible to do a conditional form confirmation message by using the redirect functionality, passing the form field value to a custom PHP page and then showing the message you want to show based on that form field value. But would take creating a custom redirect confirmation page.

    Posted 14 years ago on Wednesday July 28, 2010 | Permalink
  4. Thanks Carl, that's very helpful.

    Posted 14 years ago on Thursday July 29, 2010 | Permalink
  5. Hi guys, here is a little php snippet you can paste in your theme's functions.php file that will allow you to create custom email confirmation messages based on a drop down form field: http://pastie.org/1065325

    And here is a live sample; submit it twice with different answers to see the difference: http://gravityforms.ounceoftalent.com/2010/07/custom-confirmation-messages/

    The Breakdown

    add_filter("gform_pre_submission_filter", "update_confirmation");

    Using the gform_pre_submission_filter to modify the current form object and then pass it back to Gravity Forms to continue processing the form. The GF form object has a lot of properties that can be modified on the fly, one of those being the autoResponder property which I'll go over in a just a second.

    if($form['id'] != 6) return $form;

    Next we're making sure that we are on the right form. The form I used to test this had an id of 6, so this logic says "if this form doesn't have an id of 6, let's not doing any else and return the $form object as is.

    if($_POST['input_1'] == 'Yes!') {
    		$form['autoResponder']['message'] = 'Great! Here\'s your custom confirmation message.';
    	} else {
    		$form['autoResponder']['message'] = 'Wait? You really don\'t want a custom confirmation message?';
    	}

    Now we're ready to check the value the user submitted through our drop down field. You can access any values the user submitted through the form through the $_POST global. Want to see what's inside the $_POST after a form submission? Check out PHP's print_r function. It will output all the contents of any variable you pass to it. I've left this intact on the test form provided above so you can see what this looks like.

    You'll see (on my test form) ['input_1'] holds the value for the drop down. So if $_POST['input_1'] equals "Yes!" we can update the message property of the autoResponder property of the form (hope that isn't too confusing) and voila! You've got yourself the first custom email confirmation message.

    If $_POST['input_1'] equals anything else, they get a different custom email confirmation message. Keep in mind that you can still use tokens in these messages (ie {field_name:1}).

    $_POST['input_1']

    And the most important part... returning our modified form object.

    Haha, sorry that got a little long winded there. I guess I'm a teach-a-man-to-fish kind of guy. ;)

    Posted 14 years ago on Thursday July 29, 2010 | Permalink
  6. idealists
    Member

    Thanks David, great stuff!

    Can you also add different form fields (like you can in Admin->Notifications - All Submitted, Req. Form Fields, etc, etc) to those email messages ($form['autoResponder']['message']) based on the same conditional logic?

    Could you show an example of how to do a different "Confirmation Message" based on conditional logic too?

    Again, many thanks!

    Posted 14 years ago on Saturday July 31, 2010 | Permalink
  7. Hey Idealist, you can change the confirmation message by replacing "$form['autoResponder']['message']" with "$form['confirmation']['message']".

    Posted 14 years ago on Saturday July 31, 2010 | Permalink
  8. seventyone
    Member

    this would be a great add-on feature - many uses for conditional auto responders / emails - is it still in the works?

    Posted 13 years ago on Thursday October 14, 2010 | Permalink
  9. Yes, conditional notification message is still a planned feature for a future release.

    Posted 13 years ago on Thursday October 14, 2010 | Permalink

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