// Create database tables on theme activation function yc_create_members_table() { global $wpdb; $charset_collate = $wpdb->get_charset_collate(); $table_name = $wpdb->prefix . 'yc_members'; $sql = "CREATE TABLE IF NOT EXISTS $table_name ( id int(11) NOT NULL AUTO_INCREMENT, membership_number varchar(50) NOT NULL UNIQUE, full_name varchar(100) NOT NULL, email varchar(100) NOT NULL UNIQUE, phone varchar(20) NOT NULL, date_of_birth date NOT NULL, gender varchar(20) NOT NULL, id_number varchar(50) NOT NULL, nationality varchar(50) NOT NULL, region varchar(50) NOT NULL, county varchar(50) NOT NULL, constituency varchar(50) NOT NULL, ward varchar(50) NOT NULL, plan varchar(100) NOT NULL, receipt_number varchar(50) NOT NULL, payment_reference varchar(100) NOT NULL, amount_paid decimal(10,2) NOT NULL DEFAULT 5.00, payment_date datetime NOT NULL, status enum('active','inactive','pending') DEFAULT 'active', created_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (id), UNIQUE KEY email (email), UNIQUE KEY membership_number (membership_number), KEY phone (phone), KEY status (status) ) $charset_collate;"; require_once(ABSPATH . 'wp-admin/includes/upgrade.php'); dbDelta($sql); // Create payment logs table $log_table = $wpdb->prefix . 'yc_payment_logs'; $sql_log = "CREATE TABLE IF NOT EXISTS $log_table ( id int(11) NOT NULL AUTO_INCREMENT, email varchar(100) NOT NULL, name varchar(100) NOT NULL, payment_reference varchar(100) NOT NULL, amount decimal(10,2) NOT NULL, status enum('success','failed','pending') DEFAULT 'pending', response_data text, created_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (id), KEY email (email), KEY payment_reference (payment_reference) ) $charset_collate;"; dbDelta($sql_log); } add_action('after_switch_theme', 'yc_create_members_table'); // Also create on plugin activation if using a plugin function yc_activate_plugin() { yc_create_members_table(); } register_activation_hook(__FILE__, 'yc_activate_plugin');
Warning: Cannot modify header information - headers already sent by (output started at /home/youthsconnect/public_html/wp-content/themes/breno/functions.php:739) in /home/youthsconnect/public_html/wp-includes/pluggable.php on line 1535

Warning: Cannot modify header information - headers already sent by (output started at /home/youthsconnect/public_html/wp-content/themes/breno/functions.php:739) in /home/youthsconnect/public_html/wp-includes/pluggable.php on line 1538