Create table wordpress

Question

this code doesn’t work for me. Do you have one where I can create a table in my database?


function creation() {
  
  global $wpdb;

    $table_name = $wpdb->prefix . 'form';
 
    $sql = "CREATE TABLE $table_name (
      `id` int(11) NOT NULL AUTO_INCREMENT,
      `name` varchar(255) NOT NULL,
      `email` varchar(255) NOT NULL,
      UNIQUE KEY id (id)
    );";
   
    require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
   
}

add_action('wp', 'creation');

}
0
Javier 1 year 2020-07-22T00:11:19-05:00 0 Answers 59 views 0

Leave an answer

Browse
Browse