• All of these do NOT WORK. What I’m I missing?

    register_activation_hook(__FILE__,’teste’);
    register_deactivation_hook(__FILE__, ‘teste’);
    register_activation_hook(__FILE__,array(&$this,’teste’));
    register_deactivation_hook(__FILE__,array(&$this,’teste’));

    function teste() {
    echo “A Simple echo function to see if it works”;
    }

Viewing 6 replies - 1 through 6 (of 6 total)
  • It’s the same with me. What the heck is wrong with it. I tried looking for any output in the source but it isn’t there:

    Nothing from “echo “DBINFO:” . dbDelta($sql);” here. Only the relevant parts were copied.
    <?
    function create_links_table(){
    //Create link table
    global $wpdb;
    $table_name = $wpdb->prefix . “fim_links”;
    if($wpdb->get_var(“SHOW TABLES LIKE ‘$table_name'”) != $table_name) {
    $sql = “CREATE TABLE ” . $table_name . ” (
    order mediumint(9) NOT NULL AUTO_INCREMENT,
    href text DEFAULT ‘#’ NOT NULL,
    id text DEFAULT ‘0’ NOT NULL,
    block mediumint(9) DEFAULT ‘1’ NOT NULL,
    PRIMARY KEY order (order)
    );”;
    require_once(ABSPATH . ‘wp-admin/includes/upgrade.php’);
    echo “DBINFO:” . dbDelta($sql);
    $sql = “INSERT INTO ” . $table_name .
    ” (href, id) ” .
    “VALUES (‘https://crytekuk.info&#8217;,’link_example’)”;
    $wpdb->query($sql);
    }
    }
    function setup_fim(){
    setup_themes();
    add_option(“fim_version”,FIM_VERSION);
    add_option(“fim_widgets”,”links,ajax_login”);
    create_links_table();
    }
    register_activation_hook(__FILE__, “setup_fim”);
    ?>

    Oh, and the table isn’t created.

    me too
    so i do this :

    function silex_activation_hook(){
    ……………..
    }

    // does not work => call it directly register_activation_hook( __FILE__, ‘silex_activation_hook’);
    if ($_GET[‘activate’] == true)
    {
    silex_activation_hook();
    }

    got the same issue, did any of you guys found a solution or had implemented a work around to make it work???

    need to create tables on the DB, not able to do that since ‘register_activation_hook’ just doesn’t work..

    regards..

    See my post with sample of working code here:
    https://www.ads-software.com/support/topic/312342?replies=2#post-1226615

    Gleb

    From inside a PHP class in a plugin, this works for me:

    register_activation_hook(ABSPATH.PLUGINDIR.'/<pluginfoldername>/<pluginname>.php',array(&$this,'<functiontorun>'));

    gesman’s code looks to me to be essentially the but is not inside a class.

    You should also think about whether it is register_activation_hook that is failing or the function being called that is failing. This bit from gesman’s link is a very good way to start sorting that out:

    // If you want to quickly test if your activation hook works – put exit() into it. At least you’ll see error during activation.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘register_activation_hook JUST WON’T WORK’ is closed to new replies.