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_confirmation checkbox

  1. I'm trying to display a conditional confirmation message based on a checkbox being ticked or not in my form. I've searched the forums for this answer and cannot seem to find it.

    Here is the code:

    function custom_confirmation($confirmation, $form, $lead, $ajax){
    	if (isset($lead[3]) && $lead[3] == 1) {
                     $confirmation = array("redirect" =>"http://www.drumblebee.com/login?error=youhaveanerror");}
            else {$confirmation = array("redirect" =>"http://www.drumblebee.com/login/");}
    return $confirmation;
    }

    The problem is despite me checking (or unchecking) the box, the $lead does not seem to recognize the form value.

    The form code is:

    <input name='input_3.1' type='checkbox'  value='1'  id='choice_3_1' tabindex='3'  />

    Any help would be appreciated. I'm sure it's something very small I'm missing.

    Thanks,
    Tony

    Posted 11 years ago on Thursday December 20, 2012 | Permalink
  2. What did you hook that function to? Looks like we're missing at least one line of code.

    Posted 11 years ago on Thursday December 20, 2012 | Permalink
  3. add_action("gform_confirmation_3", "custom_confirmation", 10, 4);

    The thing is, I can get the other values from the form within the custom_confirmation function.

    $lead[1] and $lead[2] store the correct values.

    And if I go into the admin I can see that the checkbox value is stored:

    http://screencast.com/t/An9jlZEF9sm

    Thanks again!

    Posted 11 years ago on Thursday December 20, 2012 | Permalink
  4. Can you print_r or var_dump the $lead and see what the value of $lead[3] is as a debugging step?

    Posted 11 years ago on Thursday December 20, 2012 | Permalink
  5. How would I do that? It displays the confirmation page after I hit submit on the form.

    Posted 11 years ago on Thursday December 20, 2012 | Permalink
  6. If you add a print_r($entry) to your code, as the first line of your function, that should be dumped to the screen. You may need to view the source of the page to see it. If that does not work, we can always set up a log to log it there, but for quick and dirty testing, you can just print_r the entry and it should appear on screen.

    Posted 11 years ago on Thursday December 20, 2012 | Permalink
  7. I created an extremely basic log table because I couldn't get print_r to work correctly. This is the serialized array when the checkbox is checked. You can see there is a value there.

    a:21:{s:2:"id";s:3:"117";s:7:"form_id";s:1:"3";s:12:"date_created";s:19:"2012-12-20 21:35:19";s:10:"is_starred";i:0;s:7:"is_read";i:0;s:2:"ip";s:13:"50.200.57.190";s:10:"source_url";s:32:"http://www.drumblebee.com/login/";s:7:"post_id";N;s:8:"currency";s:3:"USD";s:14:"payment_status";N;s:12:"payment_date";N;s:14:"transaction_id";N;s:14:"payment_amount";N;s:12:"is_fulfilled";N;s:10:"created_by";N;s:16:"transaction_type";N;s:10:"user_agent";s:108:"Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.11 (KHTML, like Gecko) Chrome/23.0.1271.97 Safari/537.11";s:6:"status";s:6:"active";i:1;s:5:"admin";i:2;s:13:"sdkjbwiojubss dsd";s:3:"3.1";s:1:"1";}

    Posted 11 years ago on Thursday December 20, 2012 | Permalink
  8. Can anyone help on this? Trying to get the value out but not sure what to put inside the $lead[WHAT GOES HERE] variable...

    Posted 11 years ago on Friday December 21, 2012 | Permalink
  9. Nevermind - got it.

    Hopefully this will help someone else - you have to put the value inside the $lead array in quotes:

    so $remember = $lead['3.1'];

    worked.

    Posted 11 years ago on Friday December 21, 2012 | Permalink
  10. David Peralty

    I'm glad you were able to figure it out.

    Posted 11 years ago on Friday December 21, 2012 | Permalink

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