Reply To: Editing database entry error

Home Forums Quform WordPress Editing database entry error Reply To: Editing database entry error

#35878
yenfa
Participant

Hello Ally! Thank you for your assistance.

I’ve tried to check my code but I don’t know anymore what’s wrong.


add_filter('quform_post_process_2', function (array $result, Quform_Form $form) {
    global $wpdb;
    $table = 'wp9v_3_ked_fanlist_members';
 
    // The data to save/update
    $data = array(
        'name' => $form->getValue('quform_2_3'),
        'email' => $form->getValue('quform_2_11'),
        'website' => $form->getValue('quform_2_5'),
		'country' => $form->getValue('quform_2_8'),
		'code' => $form->getValue('quform_2_6'),
        'hide_email' => $form->getValue('quform_2_7')
    );
 
    $rowId = string($form->getValue('quform_2_11'));
 
    if ($rowId > 0) {
        $wpdb->update($table, $data, array('email' => $rowId));
    } else {
        $wpdb->insert($table, $data);
    }
 
    return $result;
}, 10, 2);

// update form

add_action('quform_pre_display_2', function (Quform_Form $form) {
    if (!isset($_GET['e'])) {
        return;
    }
 
    global $wpdb;
	$rowId = (string)$_GET['e'];
 
    $row = $wpdb->get_row($wpdb->prepare('SELECT * FROM wp9v_3_ked_fanlist_members WHERE email = %s', $rowId), ARRAY_A);
 
    if (!is_array($row)) {
        return $row['ID'];
    }
 
    // The form values to set
    // 
    $data = array(
        'quform_2_3' => $row['name'],
        'quform_2_11' => $row['email'],
        'quform_2_5' => $row['website'],
		'quform_2_8' => $row['country'],
		'quform_2_6' => $row['code'],
        'quform_2_7' => $row['hide_email']);
    
 
    $form->setValues($data);
});

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