Hello all!
I've been at this for more than an hour, and I think I'm obviously doing something silly.
Context: I have a volunteer sign up form where users fill out a pretty extensive amount of data. Once they have filled that out, the slightly imperfect solution I've come up with is to have them sign up for an event with their email address, and then have a pre-submission hook in functions.php use $wpdb to pull data for that one form_id, run through each row of data to see if the field_number is equal to my email field in the long form, then check for a matching email. If the email matches, then use the lead_id to pull the name and phone number for follow up.
I know I can set my hidden fields to strings, as that was the first test I did prior to starting database queries. The problem is using get_results to pull all the data, I'm getting blank values in my "Entries" for the form.
Can anybody help me see where I've gone astray?
Function:
<?php
add_action("gform_pre_submission_9", "volunteer_registration_pre_submission_handler");
function volunteer_registration_pre_submission_handler($form){
global $wpdb;
$wpdb->rg_lead_detail = $wpdb->prefix . 'rg_lead_detail';
$email = $_POST["input_1"];
$lead_id = "";
$data = $wpdb->get_results("SELECT lead_id, field_number, value FROM $wpdb->wp_rg_lead_detail WHERE form_id = '1'");
foreach($data as $data_row) {
if($data_row->field_number == "3") {
if($email == $data_row->value)
$_POST["input_4"] = "The emails match";
else
$_POST["input_4"] = "There is no match";
}
else
$_POST["input_4"] = "There are no field_numbers = 3";
}
//Store Data in form's hidden fields
//$_POST["input_4"] = $lead->lead_id;
$_POST["input_3"] = $name;
}
?>