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.

Add variable from email input into value field on check box

  1. Hello

    I have a email field, and a checkbox field.

    On my check box field, I only have one check box.

    Is it possible, on the check box value, to include the variable from the email field.

    So in my situation, the check box label is 'Subscribe to our newsletter'

    So the result would be a table column of email address who want to 'Subscribe to our newsletter'

    Any help would be great thanks.

    Josh

    Posted 7 years ago on Tuesday September 11, 2012 | Permalink
  2. Where would this table be?

    Gravity Forms will collect all your entries. If you are collecting just email and opt-in, you could export the entries for the form, then open the CSV in Excel or Google Docs or OpenOffice Calc and sort rows by the opt-in check box. If they opted in, you have their email address and opt-in.

    Does that accomplish what you need to do? This is all built in to Gravity Forms and requires no additional programming. If you have a 3rd party service you want to integrate with, we can accomplish that directly if you want. Then you don't have to export your table of email addresses and manually subscribe those users.

    Posted 7 years ago on Saturday September 15, 2012 | Permalink
  3. Indeed that is how I normally do it.

    I usually have a column which includes the word 'opt-in' and then as you say manually sort the table to retrieve the subscribers..

    However it would be better if I could get the email address from the email field, and get this email address to physically appear in the value for the Subscribe tick box.

    So instead of having a column of the word 'opt-in', instead it is a column of email address.

    Then people who don't tick the box, their cell would be blank, leaving me a column of subscriber addresses.

    If its not possible then don't worry.

    Thanks

    Posted 7 years ago on Monday September 17, 2012 | Permalink
  4. You can do this, but I am not certain of the unintended consequences. Since this is a checkbox field, it's not expecting an email address. One thing that will break for sure is the admin entry display (where there is normally a check mark when a box is checked.)

    However, if you have a form with two fields, email address in field one, and the opt-in check box as field two, and a value for the check box of 'opt-in' (the exact text is important), you can use this code to copy the email address to the opt-in check box field, when the box was checked. Add this code to your theme's functions.php. Change the 163 to your form ID and if your fields are not #1 for email and #2 for check box, you will need to adjust that as well:

    [php]
    add_action('gform_pre_submission_163', 'opt_in_to_email');
    function opt_in_to_email($form) {
    	if('opt-in' == rgpost('input_2_1'))
    		$_POST['input_2_1'] = rgpost('input_1');
    }
    Posted 7 years ago on Tuesday September 18, 2012 | Permalink