I am trying to add a table to the database upon activation of my plugin but it's not adding it. also, it's not storing the value of a global variable with add_option. please help!
here is my code
function atf_install() {
global $wpdb;
global $atf_db_version;
add_option("atf_db_version", $atf_db_version);
$table_name = $wpdb->prefix . "wptwitipid";
if($wpdb->get_var("show tables like '$table_name'") != $table_name) {
$sql = "CREATE TABLE " . $table_name . " (
id mediumint(9) NOT NULL AUTO_INCREMENT,
email varchar(120) NOT NULL,
twitid varchar(120) NOT NULL,
KEY email (email)
);";
require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
dbDelta($sql);
}
}
$atf_db_version = "1.0";
register_activation_hook(__FILE__, 'atf_install');