Support » Fixing WordPress » register_activation_hook JUST WON’T WORK

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

    register_deactivation_hook(__FILE__, ‘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 (‘’,’link_example’)”;
    function setup_fim(){
    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)

    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..


    See my post with sample of working code here:


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


    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.