Home › Forums › Quform WordPress › Cannot retrieve field value in PHP custom plugin › Reply To: Cannot retrieve field value in PHP custom plugin
August 25, 2020 at 12:10 pm #31813
Labella
Participant
Good morning, I’ll try to explain:
I‘m passing a parameter via shortcode to a hidden field
Then I want to use that field value to populate some other hidden fields. To populate those fields I have to pick data from an external database with a sql query, so I was trying to do it with a custom php plugin. This is the code:
if ($mysqli->connect_errno) {
printf("Connessione al db fallita: %s\n", $mysqli->connect_error);
exit();
}
$query = "SELECT nome, sessione, anno, prezzo, paypal FROM corsi_new WHERE id_iscrizione='".$corso."'";
$result = $mysqli->query($query);
$row = $result->fetch_row();
$corsoid=$row[0]."-".$row[1]."-".$row[2];
add_filter('quform_element_value_Titolo-corso', function ($value) use ($row) {
return $row[0];
});
add_filter('quform_element_value_Sessione', function ($value) use ($row) {
return $row[1];
});
add_filter('quform_element_value_Anno', function ($value) use ($row) {
return $row[2];
});
add_filter('quform_element_value_CorsoID', function ($value) use ($row) {
return $corsoid;
});
add_filter('quform_element_value_Prezzo', function ($value) use ($row) {
return $row[3];
});
add_filter('quform_element_value_Paypal', function ($value) use ($row) {
return $row[4];
});