Problems with register_activation_hook
-
I’ve created my first plugin for WP and I was hoping to release, so I decided to add an install function which would set up the database to save people some hassle, but it doesn’t seem to work.
I get no errors, but the table just isn’t created.
Here’s the code I’m using:
global $wpdb; $tableName = $wpdb->prefix . 'tweets'; $twitterUserName = "jonlambell"; $tweetLimit = 5; function tweet_install() { global $wpdb; global $tableName; if($wpdb->get_var("SHOW TABLES LIKE '$tableName'") != $tableName) { $sql = "CREATE TABLE " . $tableName . " ( id bigint(255) NOT NULL, name varchar(255) NOT NULL, img varchar(255) NOT NULL, msg varchar(255) NOT NULL, time varchar(255) NOT NULL, PRIMARY KEY (id) );"; require_once(ABSPATH . 'wp-admin/includes/upgrade.php'); dbDelta($sql); } } register_activation_hook(__FILE__,'tweet_install');
Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)
The topic ‘Problems with register_activation_hook’ is closed to new replies.