The MU forums have moved to WordPress.org

Create extra table during signup (4 posts)

  1. jweggemans
    Member
    Posted 14 years ago #

    I want to add an extra table during the signup/activate process..

    I've added the table in schema.php but that doesn't seem to work. I can't find any other CREATE statements in the code.

    Where can I add this extra table?

  2. DailyTestimony
    Member
    Posted 14 years ago #

    I would write a php function and drop the file in mu-plugins

    use add_action() to execute your function when the user registers

    see http://codex.wordpress.org/Function_Reference/add_action

    for more info on add_action

  3. jweggemans
    Member
    Posted 14 years ago #

    That looks so simple! Thanks for pointing it out!

  4. jweggemans
    Member
    Posted 14 years ago #

    This works for me. Thanks!


    <?php
    // add the mailer tables after signup
    function mailer_make_tables($ID) {
    global $wpdb;

    $table_name = "wp_" . $ID . "_mailer";

    $query = "CREATE TABLE $table_name (
    mail_id bigint(20) NOT NULL auto_increment,
    mail_address varchar(255) NOT NULL,
    mail_name varchar(255) NOT NULL,
    PRIMARY KEY (mail_id))
    ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=33";
    $wpdb->query($query);

    return true;
    }
    add_action('user_register', 'mailer_make_tables');
    ?>

About this Topic

  • Started 14 years ago by jweggemans
  • Latest reply from jweggemans