Add rating

This commit is contained in:
2026-05-06 21:27:34 +02:00
parent 9e8b404f91
commit 67c5c98fb4
4 changed files with 18 additions and 10 deletions

View File

@@ -33,8 +33,9 @@ function go_form_activate()
country varchar(100) DEFAULT NULL,
club varchar(100) DEFAULT NULL,
rank tinyint(2) DEFAULT 0,
rating smallint(5) DEFAULT 0,
email varchar(255) DEFAULT NULL,
egd_number varchar(50) DEFAULT NULL,
egd_number varchar(20) DEFAULT NULL,
comment text DEFAULT NULL,
created_at datetime DEFAULT CURRENT_TIMESTAMP NOT NULL,
PRIMARY KEY (id),
@@ -55,8 +56,8 @@ function go_form_uninstall()
$wpdb->query("DROP TABLE IF EXISTS {$wpdb->prefix}go_form_entries");
$wpdb->query("DROP TABLE IF EXISTS {$wpdb->prefix}go_form_forms");
}
register_uninstall_hook(__FILE__, 'go_form_uninstall');
//register_uninstall_hook(__FILE__, 'go_form_uninstall');
register_deactivation_hook(__FILE__, 'go_form_uninstall');
// ========== Helpers ==========
$ranks = [
0 => '30k', 1 => '29k', 2 => '28k', 3 => '27k', 4 => '26k',
@@ -117,13 +118,20 @@ function go_form_handle_submission()
$form_id = 1; // Fallback to default form
}
$rating = intval($_POST['rating']);
$rank = intval($_POST['rank']);
if($rating < -900) {
$rating = ($rank * 100) - 900;
}
$data = [
'form_id' => $form_id,
'first_name' => sanitize_text_field($_POST['first_name']),
'last_name' => sanitize_text_field($_POST['last_name']),
'country' => sanitize_text_field($_POST['country'] ?? ''),
'club' => sanitize_text_field($_POST['club'] ?? ''),
'rank' => intval($_POST['rank']),
'rank' => $rank,
'rating' => $rating,
'email' => sanitize_email($_POST['email'] ?? ''),
'egd_number' => sanitize_text_field($_POST['egd_number'] ?? ''),
'comment' => sanitize_textarea_field($_POST['comment'] ?? '')
@@ -133,10 +141,6 @@ function go_form_handle_submission()
wp_redirect($_SERVER['HTTP_REFERER']);
exit;
}
if ($data['rank'] < 0 || $data['rank'] > 47) {
wp_redirect($_SERVER['HTTP_REFERER']);
exit;
}
$wpdb->insert("{$wpdb->prefix}go_form_entries", $data);
wp_redirect($_SERVER['HTTP_REFERER']);