function create_plugin_table() {
global $wpdb;
$tablename = $wpdb->prefix . 'dati_user';
// controllo se la tabella essite o meno nel db
if($wpdb->get_var("show tables like '$tablename'") != $tablename){
//recupero il charset
$charset_collate = $wpdb->get_charset_collate();
//creo la tabella con quel prefisso
$sql = "CREATE TABLE $table_name (
id bigint(20) NOT NULL AUTO_INCREMENT,
p_iva varchar(30),
c_f varchar(30),
UNIQUE KEY id (id)
) $charset_collate;";
require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
dbDelta($sql);
}
}
//chiama la funzione all'attivazione del plugin
register_activation_hook(__FILE__,'create_plugin_table');