I have a $_SESSION variable set call $_SESSION['gwf_email'] Basically what I want to do is use the value stored within this variable to populate the "Send To Email" field on a form. Is this possible?
I have a $_SESSION variable set call $_SESSION['gwf_email'] Basically what I want to do is use the value stored within this variable to populate the "Send To Email" field on a form. Is this possible?
Hi, imagebox,
Yes, you can do this. In the admin, you need to go to the Advanced tab for your field and check "Allow field to be populated dynamically" and then give the field a unique name. You can then use the "gform_field_value_$parameter_name" hook (http://www.gravityhelp.com/documentation/page/Gform_field_value_$parameter_name) to populate the field with your session variable.
Let me know if you have questions.
I think I may not have been clear. What I am trying to do is populate the field value of the field in the admin panel in which you type in the email address of the person you wish to have form entries emailed to.
If I a hidden field on the form which is capturing and storing the value of $_SESSION['gwf_email'] , How do I feed that value to the field which decides who should receive the new form submission ?
Ah, for that we have two hooks, one for the Notification to User and one for the Notification to Administrator. Both of these hooks will allow you to use a value from the posted form. Take a look at these and let me know if you have questions.
For the user notification email, there is the "gform_autoresponder_email" hook (http://www.gravityhelp.com/documentation/page/Gform_autoresponder_email).
For the admin notification email, there is the "gform_notification_email" (http://www.gravityhelp.com/documentation/page/Gform_notification_email)
Also the hidden field is not populating the value.
This is the HTML code being rendered within the form on the page (http://globalwealthfactor.com/test-form/)
<li id="field_1_8" class="gfield gform_hidden">
<input id="input_1_8" class="gform_hidden" type="hidden" value="" name="input_8">
</li>
This is what I have in my functions file:
add_filter("gform_field_value_email", "sponsor_email");
function sponsor_email($value){
return $_SESSION['gwf_email'];
}
You can see a screen shot of the field properties at : http://globalwealthfactor.com/wp-content/themes/stealth-child/images/gf-scrn-shot.jpg
Thank you :-)
Make sure you use the parameter name you setup in the admin when calling the hook. So, since the parameter name is "sponsor_email", your code should be:
add_filter("gform_field_value_sponsor_email", "sponsor_email");
function sponsor_email($value){
return $_SESSION['gwf_email'];
}