Forum Replies Created

Viewing 4 replies - 1 through 4 (of 4 total)
  • I’ve tried both solutions and I cannot make it work, I could really use some hint here:

    I’ve tried:

    add_action(‘activate_folder/plugin.php’, ‘function’);

    and also:

    $myrelpath = preg_replace(‘.*wp-content.plugins.’,”,__FILE__);
    add_action(‘activate_’.$myrelpath,’function’);

    But it seems that my function for installing my SQL TABLES
    doesn’t get initiated. Is there something that I’m missing?
    I have read CREATING TABLES WITH PLUGINS, but nothing seems to help.

    I have put my install-function in its own php-file and placed it in ../plugins/ along with my plogin.php file.

    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?

    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’);

    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.

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