activate_your-plugin.php is an action hook. To learn more about what that means, see the Codex here.
Basically, that means that you could write a function, say lgoodbar_function, and have it fire off whenever your plugin is activated. The code would look like this:
function lgoodbar_function () {
... do exciting stuff when my plugin is activated !...
}
add_action('activate_your-plugin.php','lgoodbar_function');
Thanks very much, that was exactly what I was looking for!
Loyd
Im trying to use:
add_action(‘activate_your-plugin.php’,’lgoodbar_function’);
But I must do something wrong cause nothing works.
Im trying to create tables and I’ve read all about $wpdb and how to use activate_ hook to trigger my install.php when plugin installed. Maybe I type in the wrong pluginurl or maybe I put my install.php the wrong place. Can someone please help me with an example or maybe a hint about how to debug my installer.
To be more specific this is what I try, but I cannot get it to work. My plugin “myplugin.php” is ofcourse placed in
/plugins/myplugin.php
and my install.php is placed in the same directory.
This is the code:
function my_install() {
global $wpdb;
$wpdb->show_errors();
$sql = “CREATE TABLE myTable (
id MEDIUMINT(9) AUTO_INCREMENT,
content TEXT,
PRIMARY KEY (images_id), );”;
require_once(ABSPATH . wp-admin/upgrade-functions.php’);
dbDelta($sql);
}
add_action(‘activate_myplugin.php’, ‘my_install’);
UPS, sorry Im a newbe:
function my_install() {
global $wpdb;
$sql = “CREATE TABLE my_images (
id MEDIUMINT(9) AUTO_INCREMENT,
content TEXT,
PRIMARY KEY (id),
);”;
require_once(ABSPATH . ‘wp-admin/upgrade-functions.php’);
dbDelta($sql);
}
add_action(‘activate_my_plugin.php’,’my_install’);
BUT it still doesn’t work?