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.

Confirm E-mail Variable

  1. As usual I'm styling gforms to the max. On this occasion I've got a email field with with confirm email field.

    I've removed the input labels, and am using variables as my labels.

    My problem is I can only get a variable in the first email field - is there a way using the functions.php to a manually add the confirm email variable?

    #input_6_6 ...this has variable set using gf admin panel
    #input_6_6_2 ...this confirm email field I need a variable on

    Any direction would be great thanks.

    Posted 11 years ago on Friday October 14, 2011 | Permalink
  2. Hi Provdes,

    This input does not provide a dynamic population parameter; however, if you know the field ID you can populate via the gform_pre_render hook.

    [php]
    add_filter('gform_pre_render', 'add_confirm_value');
    function add_confirm_value($form){
    
        $_POST['input_3_2'] = 'david@rocketgenius.com';
    
        return $form;
    }
    Posted 11 years ago on Friday October 14, 2011 | Permalink
  3. So, I'm curious, if you're pre-populating both the of the fields, then you're not really asking the user to confirm the email address by re-typing it themselves. Why not just pass the value to a normal email field with no confirmation? The confirmation field is providing no real benefit at this point.

    Posted 11 years ago on Friday October 14, 2011 | Permalink
  4. Thanks David but I'm not getting a result though from the hook.

    I've inserted the code below

    add_filter('gform_pre_render', 'add_confirm_value');
    function add_confirm_value($form){
        $_POST['input_6_6_2'] = 'Confirm Your E-mail';
        return $form;
    }

    And added this into the functions.php, inside the PHP tags, and is still not adding a variable.

    I used firebug to get the ID of the of the input which is #input_6_6_2

    Am I missing something?

    @Kevin - this is purely for a design purpose, I'm using jQuery to clear the value when the input is clicked, and I am just using these variables for label purposes.

    Posted 11 years ago on Monday October 17, 2011 | Permalink
  5. You should remove the form ID from the input. It should look more like this:

    input_6_2

    If you var_dump the $_POST with your function, you will see the actual input IDs you need to target.

    Posted 11 years ago on Tuesday October 18, 2011 | Permalink
  6. Hi Chris, I don't want to sound stupid, but I don't understand the "var_dump the $_POST"

    If you roll over the fields in a CSS edit or firebug it reveals the the input ID

    My input ID's for the confirmation email field is:

    #input_6_6 - this is the 'your email' input ID
    #input_6_6_2 - this is the 'confirmation email' input ID

    Can't figure it out!

    Posted 11 years ago on Wednesday October 19, 2011 | Permalink
  7. Sorry, you were getting pretty technical so I didn't think to explain it.

    You can use the PHP function var_dump to view what's in the $_POST array. That way, you know exactly the right name to use in your functions. You can insert var_dump("$_POST"); into your code, and the contents of the $_POST variable will be dumped. Where it gets dumped depends on where you insert the code.

    I sometimes write to a file on the server, or instead I email the contents of the array. Since we know $_POST is an array, it's safe to use the "print_r" function, instead of var_dump, like this:

    [php]
    // format: email address, subject line, body
    // the "true" parameter for print_r tells it to return the array, not echo it
    wp_mail("chris@rocketgenius.com", "Subject line var_dump of post variable", print_r("$_POST", true));

    That will email you nice looking output from the $_POST array, and you can see the names of your inputs there.

    Is this form 6? If so, you should remove the first 6, after #input_ and I think it will be fine.

    Posted 11 years ago on Wednesday October 19, 2011 | Permalink
  8. Thanks Chris worked at beaut!!!

    You we're right was the first 6 from my input ID that was causing the issue.

    Big thanks for your time and help!

    Posted 11 years ago on Wednesday October 19, 2011 | Permalink
  9. Glad to have helped.

    Posted 11 years ago on Wednesday October 19, 2011 | Permalink

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