WordPress.org

Ready to get started?Download WordPress

Forums

myCRED
[resolved] Integration between multiple sites (8 posts)

  1. godavid33
    Member
    Posted 5 months ago #

    I need to set the plugin up so the same points system is used between two different wordpress installs. I plan on sharing a user database (which I still need to figure out how to do). I know that there is a remote API, do I need to manually configure this on the remote site in order for it to add and deduct points or is there a way I can configure the remote plugin to automatically do all points functions on the primary site?

    https://wordpress.org/plugins/mycred/

  2. Gabriel
    Member
    Plugin Author

    Posted 5 months ago #

    Hey.

    Thank you for your question.
    There are several ways to accomplish this and it all depends on how these two websites are connected.

    If you have two separate websites on two different servers then the remove API would be the way to go. If on the other hand you are using a multisite or have two sites on the same server with their user and usermeta tables shared, then the remote API would be overkill.

    When it comes to the Remote API, you should see it as a "car engine". I provide you with the engine but it is up to you to design and built the car it will power. There are simply way to many features the API can offer for me to build something that will suit all myCRED users. There are a lot of things you need to take into consideration like what type of security you want since the Remote API would allow outsides to adjust / query your users point balances.

    You are welcome to contact me directly via the myCRED website if you have any further queries or need assistance with the Remote API.

  3. godavid33
    Member
    Posted 5 months ago #

    Okay, so the remote API will probably be overkill in my case. Same server, going to be implementing a shared database. How would you suggest going about sharing the points system between both sites? Is there a way I can point the secondary install of MyCred to the primary MyCred databases (i.e. ideally just set the prefix to look for)?

  4. Gabriel
    Member
    Plugin Author

    Posted 5 months ago #

    If you are not going to use Multisite, then you would need to do the following:

    1. Have myCRED installed and setup on your "main site".
    2. On your second website, before enabling myCRED, add the following to your wp-config.php file:

    define( 'MYCRED_LOG_TABLE', 'your_main_sites_mycred_log_table' );

    Replace the dummy text with your main sites log table name so if your main sites db prefix is wp_ while your second site is other_ then the code would be:

    define( 'MYCRED_LOG_TABLE', 'wp_myCRED_log' );

    If you are unsure what the table name is, just go to your db admin area and check the table name. myCRED always names it myCRED_log but if you have been using myCRED since 1.0 then it might be mycred_Log.

    3. Now enable myCRED on your second site and run the setup. Since the table will exist, myCRED will skip the install and you will be able to see your main sites log and users balance on your second site.

    Now at this stage, both sites will share the log and since you are using the same usermeta table (where the balance is stored) on both sites everyones balance will be the same on both sites.

    But this is where it ends. Since you are not using Multisite, you do not have access to the "Master Template" feature. This means that each site will have to be setup separate with regards of hooks and add-ons. If you want both sites to give the same amount of points then you will need to update myCRED on both sites to match.

    The "Master Template" feature basically overrides all other sites settings with your main sites. But it requires Multisite and myCRED being network wide enabled.

    I hope it all makes sense.
    Let me know if you require further assistance.

  5. godavid33
    Member
    Posted 5 months ago #

    Great reply! I hope I can be as responsive as you when I am a plugin author haha.

    So I made the change and it definitely seems to have worked (shared user DB, shared log) but when I get the balance on the second site it is still showing the old users balance. I'm thinking this is possibly because I had previously had myCred installed. Though I deactivated and deleted it prior to defining the myCred log table in the "secondary" site. Is there another table that houses balances? Could it be a cache problem?

    Thanks!
    Gabe

  6. Gabriel
    Member
    Plugin Author

    Posted 5 months ago #

    Users balances are stored in your user meta table under the "mycred_default" key. If you connect both sites users and usermeta tables then on all sits you should see the balance as all sites will pull the balance from the same table.

  7. godavid33
    Member
    Posted 5 months ago #

    Thank you very much!

    I ran into some problems wrought by my own hand due to omitting an underscore from CUSTOM_USER_META_TABLE (doh >< )

    I hope when I'm a plugin author I can be half as responsive and helpful as you are. Cheers!

  8. Gabriel
    Member
    Plugin Author

    Posted 5 months ago #

    Excellent. Yeah, I have been there myself, staring myself blind at the smallest mistake and appreciate the kind words. Have fun and let me know if you require further assistance.

Reply

You must log in to post.

About this Plugin

About this Topic