Reply To: Cannot retrieve field value in PHP custom plugin

Home Forums Quform WordPress Cannot retrieve field value in PHP custom plugin Reply To: Cannot retrieve field value in PHP custom plugin

#31827
Labella
Participant

Thank you, but i’m still stuck (sorry..)

I set “Mixaggio” as default parameter for field 1_111, but this doesn’t work:

 
<?php
 
/*
 * Plugin Name: Quform Custom Code
 * Description: Custom code for Quform.
 * Version: 1.0
 */
 
// Paste in your custom code below

add_action('quform_pre_display', function (Quform_Form $form) {
    
    
    $corso = $form->getValueText(‘quform_1_111’);
    
    $mysqli = new mysqli("*******", "*******", "*******", "*******");

	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();

    
	$form->setValue('quform_1_114', $row[0]);
 
 
});

whereas this works:

 
<?php
 
/*
 * Plugin Name: Quform Custom Code
 * Description: Custom code for Quform.
 * Version: 1.0
 */
 
// Paste in your custom code below

add_action('quform_pre_display', function (Quform_Form $form) {
    
    
    $corso = $form->getValueText(‘quform_1_111’);
    
    $mysqli = new mysqli("*******", "*******", "*******", "*******");

	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='Mixaggio'";

	$result = $mysqli->query($query);

	$row = $result->fetch_row();

    
	$form->setValue('quform_1_114', $row[0]);
 
 
});

Maybe the field 1_111 acquires his default parameter after my $form->getValueText(‘quform_1_111’) request? I don’t understand where is the error. Please help me 🙏

Be inspired. © 2020 ThemeCatcher Ltd. 20-22 Wenlock Road, London, England, N1 7GU | Company No. 08120384 | Built with React | Privacy Policy