I am trying to add new table and alter the wp-users table to add new column. The first sql is working great i.e creating new table but the 2nd sql for adding new column is not working. Any help would be great. here is the code:
global $wpdb;
$table_name = $wpdb->prefix . "message";
require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
$sql ="CREATE TABLE IF NOT EXISTS $table_name (
id int(11) NOT NULL AUTO_INCREMENT,
user_sender int(11) NOT NULL,
user_receiver int(11) NOT NULL,
message varchar(255) NOT NULL,
chat_read tinyint(1) NOT NULL,
chat_time TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (id)
) ENGINE=InnoDB AUTO_INCREMENT=11 DEFAULT CHARSET=latin1";
dbDelta($sql);
$sql = "ALTER TABLE $wpdb->users
ADD COLUMN visibility VARCHAR(50) NOT NULL AFTER display_name,
ADD COLUMN user_last_activity TIMESTAMP DEFAULT CURRENT_TIMESTAMP AFTER visibility";
dbDelta($ql);
Aucun commentaire:
Enregistrer un commentaire