This snippet provides the ability to specify conditional confirmations in Gravity Forms. Want to redirect users to a different page based on a value they select on the form? Or just show them a different confirmation message? This functionality will be available in Gravity Forms relatively soon, but for those of you who need this now, here is a nice an easy solution!
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 |
|
How do I install this snippet?
Just copy and paste this snippet to your theme’s functions.php file.
Do I need to configure this snippet to work with my form?
Yes. First of all, you’ll want to remove the examples from the bottom of the snippet that you do not need. Next, you’ll want to either modify one of the examples to suit your needs or you can create your own.
GWConditionalConfirmations::add_conditional_confirmation($form_id, $field_id, $operator, $value, $confirmation);
- The
$form_id
parameter should be the ID of the form for which you would like to register a conditional confirmation. - The
$field_id
parameter should be the ID of the field for which you would like to base the confirmation condition. - The
$operator
parameter should be the operator which will be used to compare the submitted field value against the specified value passed in the $value parameter. Accepted values are"is"
,"isnot"
,"greater_than"
,"less_than"
,"contains"
,"starts_with"
, “ends_with"
. - The
$value
parameter is the value to which submitted field value will be compared to. - The
$confirmation
parameter should be the type and corresponding value of that confirmation type. Acceptable values are:array('redirect' => 'http:://yoururl.com')
array('page' => 12)
'Plain text confirmation!'
Make sure you take another look at the examples too:
1 2 3 4 5 6 7 8 9 10 |
|
Summary
If you come across any bugs, let me know in the comments. Hope this proves to be a good stop gap solution until this functionality makes it into the core.