0

Well, I finished my first plugin in WordPress but I have a little problem.

My plugin have the next code

add_action('my-plugin/my-plugin.php','rating_install'); add_action('admin_menu','rating_add_option'); function rating_install(){ global $wpdb; $table_name = $wpdb->prefix."rating"; $create = "CRETA TABLE ".$table_name." ( " . "id INT( 11 ) NOT NULL AUTO_INCREMENT PRIMARY KEY, " . "url TINYTEXT NOT NULL, " . "descripcion TINYTEXT NOT NULL ) "; $wpdb->query($create); } function rating_uninstall(){ global $wpdb; $table_name = $wpdb->prefix."rating"; $drop = "DROP TABLE IF EXISTS ".$table_name; $wpdb->query($drop); } add_action('activa_rating/my-plugin.php','rating_install'); add_action('desactiva_rating/my-plugin.php','rating_uninstall'); 

And it's works in localhost when I active my plugin, but when I upload the plugin to my server this code isn't work, like it's doesn't exists. Don't create my table in the database.

I'm see the privilege in the database and I've all the privileges.

2
  • I think you have the Wrong action names in your add_action calls. you should use register_activation_hook and register_deactivation_hook or maybe register_uninstall_hook. Commented Sep 29, 2014 at 8:57
  • i think you used creta it should be create Commented Sep 15, 2015 at 10:31

1 Answer 1

0

Use this code

register_activation_hook(__FILE__, 'rating_install'); register_deactivation_hook(__FILE__, 'rating_uninstall'); function rating_install(){ global $wpdb; $table_name = $wpdb->prefix."rating"; $create = "CRETA TABLE ".$table_name." ( " . "id INT( 11 ) NOT NULL AUTO_INCREMENT PRIMARY KEY, " . "url TINYTEXT NOT NULL, " . "descripcion TINYTEXT NOT NULL ) "; $wpdb->query($create); } function rating_uninstall(){ global $wpdb; $table_name = $wpdb->prefix."rating"; $drop = "DROP TABLE IF EXISTS ".$table_name; $wpdb->query($drop); } 

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.