Extending Plugin for Shared Multisite Database

Ok, this is kind of a complicated question.

Let me explain what's going on. I use Events Made Easy to manage our itineraries on minutemenministries.org (There is also a support forum and documentation; I've attached the plugin file for your reference as well). Basically, I want the events one site to be mirrored on all sites in the "Minutemen Network" (Wordpress multisite). Currently, the EME plugin installed on each site reflect different data. That is because, it seems, that the multisite actually prefixes the db tables with a unique id: "wp_" for the original site (minutemenministries.org), "wp_3_" for the second site (jimvangelderen.org). See phpMyAdmin screenshot below.

What I would like to do is to somehow "trick" the satellite sites to always use the "wp_" tables for the EME plugin. As far as I can understand this would solve everything. As long as each satellite site is "tricked" all the data entered is available and editable to every site. I think.

Now as far as extending the plugin itself, I am not sure how that is going to work. From what rooting around I could do I found that in events_manager.php, on lines 115-123 it defines variables for "eme_answers", "eme bookings", "eme_categories", etc from the tables above. I searched for these variables and found that just about each time they are used, the code "$wpdb->prefix." is affixed before it. From what I can tell from this codex document, "$wpdb" is a Wordpress global variable for talking to the database and "prefix" is a class variable that adds the aforementioned prefixes to the tables. In the same codex document, right below the definition for "$prefix", it talks about about another class variable, "$base_prefix", saying:

The original prefix as defined in wp-config.php. For multi-site: Use if you want to get the prefix without the blog number appended.

That might just be what I'm looking for! So then, my question is this. How can I extend this plugin to do what I want it to do?

  • Vaughan
    • Support/SLS MockingJay

    Hi @bobby,

    I think there would be more to it than just changing that. It would take lots of custom coding in the plugin to make this work in that way, you are talking about global tables.

    In theory, it might be possible to replace $wpdb->prefix with $wpdb->base_prefix, which you could try, though I would set up a test site before trying this on a live site. I can't say for sure whether this will give you any issues or not. You certainly would need to be selective in which references you changed it.

    There is an events plugin that already has global tables function. http://wp-events-plugin.com/documentation/multisite/

    Hope this helps

  • Vaughan
    • Support/SLS MockingJay


    Probably not in this case because of the context of your changes, unless the plugin has hooks & actions for every function where you need to change the code, which is a bit unlikely in many cases. But I could be wrong there, it depends on how well it's coded.


Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.