Title: activate plugin function WP 2.0 (development)
Last modified: August 18, 2016

---

# activate plugin function WP 2.0 (development)

 *  [lgoodbar](https://wordpress.org/support/users/lgoodbar/)
 * (@lgoodbar)
 * [20 years, 5 months ago](https://wordpress.org/support/topic/activate-plugin-function-wp-20-development/)
 * I’m working on a plugin, and need to know if the user has
    activated it. I noticed
   in wp-admin/plugins.php there’s an action called activate_ + trim($_get(plugin)).
 * If I read it right, it would send off to a function called
    activate_plugin.php.
   However, you can’t create a function with a period in its name. Has anyone used
   these successfully?
 * I browsed through wp-admin/plugins.php to see the call code,
    and wp-includes/
   functions.php (line 1235) but didn’t see anything that would either get rid of
   the .php or remove the period to give activate_pluginphp.
 * Any help appreciated!
 * Thanks,
    Loyd

Viewing 5 replies - 1 through 5 (of 5 total)

 *  [Austin Matzko](https://wordpress.org/support/users/filosofo/)
 * (@filosofo)
 * [20 years, 5 months ago](https://wordpress.org/support/topic/activate-plugin-function-wp-20-development/#post-310278)
 * activate_your-plugin.php is an action hook. To learn more about what that means,
   see the Codex [here](http://codex.wordpress.org/Plugin_API).
 * 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');
 *  Thread Starter [lgoodbar](https://wordpress.org/support/users/lgoodbar/)
 * (@lgoodbar)
 * [20 years, 5 months ago](https://wordpress.org/support/topic/activate-plugin-function-wp-20-development/#post-310573)
 * Thanks very much, that was exactly what I was looking for!
    Loyd
 *  [nkoenig](https://wordpress.org/support/users/nkoenig/)
 * (@nkoenig)
 * [19 years, 5 months ago](https://wordpress.org/support/topic/activate-plugin-function-wp-20-development/#post-310857)
 * 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.
 *  [nkoenig](https://wordpress.org/support/users/nkoenig/)
 * (@nkoenig)
 * [19 years, 5 months ago](https://wordpress.org/support/topic/activate-plugin-function-wp-20-development/#post-310858)
 * 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’);
 *  [nkoenig](https://wordpress.org/support/users/nkoenig/)
 * (@nkoenig)
 * [19 years, 5 months ago](https://wordpress.org/support/topic/activate-plugin-function-wp-20-development/#post-310859)
 * 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?

Viewing 5 replies - 1 through 5 (of 5 total)

The topic ‘activate plugin function WP 2.0 (development)’ is closed to new replies.

## Tags

 * [activate](https://wordpress.org/support/topic-tag/activate/)
 * [development](https://wordpress.org/support/topic-tag/development/)
 * [function](https://wordpress.org/support/topic-tag/function/)

 * 5 replies
 * 3 participants
 * Last reply from: [nkoenig](https://wordpress.org/support/users/nkoenig/)
 * Last activity: [19 years, 5 months ago](https://wordpress.org/support/topic/activate-plugin-function-wp-20-development/#post-310859)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
