Support » Networking WordPress » Custom multisite plugin not creating tables

  • Hi

    I’m trying to write a custom plugin for a multisite installation.
    I’m using Shiba’s method from here

    It’s not creating the tables and I’m getting this message on activation:

    The plugin generated 2412 characters of unexpected output during activation.

    Here’s my complete plugin code:

    Plugin Name: Messages
    Plugin URI:
    Description: Messages Plugin
    Version: 0.1
    Author: Whoever
    class msgLoader {
    	function msgLoader() {
    		register_activation_hook( __FILE__, 'multisiteActivate' );
    	function create_inbox_table($table_name) {
    		global $wpdb;
    			$sql = "CREATE TABLE IF NOT EXISTS '$table_name' (
    			  	id bigint(20) NOT NULL AUTO_INCREMENT,
    				from varchar(255) NOT NULL,
    			  	message varchar(255) DEFAULT NULL,
    			  	UNIQUE KEY id (id)
    		require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
    	function multisiteActivate() {
    		global $wpdb;
    		if (function_exists('is_multisite') && is_multisite()) {
    			// check if it is a network activation - if so, run the activation function for each blog id
    			if (isset($_GET['networkwide']) && ($_GET['networkwide'] == 1)) {
    		                $old_blog = $wpdb->blogid;
    				// Get all blog ids
    				$blogids = $wpdb->get_col($wpdb->prepare("SELECT blog_id FROM $wpdb->blogs"));
    				foreach ($blogids as $blog_id) {
    	function activate() {
    		global $wpdb;
    	        $table_name = $wpdb->prefix . 'inbox';
    			if ($wpdb->get_var( "SHOW TABLES LIKE '$table_name'") != $table_name) {
    global $msg;
    $msg = new msgLoader();

    Any help would be greatly appreciated.

    Thanks in advance


Viewing 1 replies (of 1 total)
  • The problem in your code may lie in the interaction between HyperDb (which I suppose you have installed) and

    $wpdb->get_var( "SHOW TABLES LIKE '$table_name'") != $table_name) {

    since Hyperdb::get_table_from_query() does not understand such queries.

    I posted a patch upstream for consideration as of today, I’ll keep you posted if it gets into the mainline, in case this is your problem.

Viewing 1 replies (of 1 total)
  • The topic ‘Custom multisite plugin not creating tables’ is closed to new replies.