0

I would like to know how can I make my supportcandy plugin to read the database tables of another supportcandy plugin installed in another site, without activating the wordpress multisite feature.

I actually have 2 subdomains sharing the same database, but both with different database prefixes. Subdomain A has prefix abtf_ for its tables and subdomain B has prefix klmn_ for its tables. They both share the users, and the userdata, the keys, and cookies via the wp-config.php file. I made the needed changes in both configuration files and both wordpress installations work pretty fine. But my headeache comes when I try to make them share the plugin’s tables.

I want both installations of supportcandy to use the same database tables, and I don`t know really how to do it, I’ve been researching for days, I tried to do something similar as I did in the wp-config.php for linking both sites, but didn’t work, I tried by building an alternative wp-config.php just for supportcandy, and testing inside the plugin files to make it read the alternative wp-config.php, I tried to define custom constants inside wp-config…

I’m totally lost. If someone could give me a hand, I would really appreciate it.

Thank you in advance!

1
  • Normally wouldn't suggest sharing a database across two sites, doing so can and likely will cause issues. No one will suggest it, and even I would advise against it, but your best bet might be to edit the SupportCandy plugin files, there will likely be a database class making it much easier to swap out the prefix for just that plugin.
    – FluxCoder
    May 10, 2023 at 9:34

1 Answer 1

0

I've created an alternative wp-config.php and renamed to wp-config2.php with the same configuration except for the table prefix. Then I tried by editing all the plugin files. At the top of each file I found:

if ( ! defined( 'ABSPATH' ) ) {

exit; // Exit if accessed directly!

}

And I replaced it for:

require_once(ABSPATH . ‘wp-config2.php’);

$connection = mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD);

mysqli_select_db($connection, DB_NAME);

But doesn't work. The plugin keeps connecting to the original tables instead of the tables I want it to connect to... I don't know what I've missing :S

1
  • Please edit your question to include this information rather than posting it as an answer.
    – Pat J
    May 17, 2023 at 13:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.