Sync several WP installs to 1 DB

Discussion in 'aMember Pro v.4' started by slinky, Dec 7, 2011.

  1. slinky

    slinky Member

    Joined:
    Jul 15, 2010
    Messages:
    200
    I was wondering whether amember 4 can sync a couple of Wordpress installs into one amember login. In theory, this should work just fine by just creating a different named Wordpress plugin. The only pain is that metadata will be different in each blog (e.g. user bio) but at least login sync is accomplished.

    Ken just responded to me... I guess it works in theory.
  2. alexander

    alexander Administrator Staff Member

    Joined:
    Jan 8, 2003
    Messages:
    6,279
    Sure this can be done. Jsut need to create separate copy of wordpress plugin for each blog.

    Just duplicate plugin files then rename classes within wordpress.php
  3. slinky

    slinky Member

    Joined:
    Jul 15, 2010
    Messages:
    200
    Alexander - I've read this but I'm not sure where wordpress.php is - I don't see it in the entire plugin package or in the wordpress module for amember. perhaps you can explain just a little further?
  4. alexander

    alexander Administrator Staff Member

    Joined:
    Jan 8, 2003
    Messages:
    6,279
    it should be in /amember/application/default/plugins/protect/wordpress/ folder.
    So, copy folder to wordpress1 then rename wordpress1/wordpress.php to wordpress1/wordpress1.php then change wordpress to wordpress1 in classes names inside wordpress1.php
  5. slinky

    slinky Member

    Joined:
    Jul 15, 2010
    Messages:
    200
    Thanks - I was looking at v3 since it's what I'm still using. I guess the plugin system is now much different in v4 which means that my custom plugins will also need to be modified. Thanks.
  6. davidm1

    davidm1 aMember User & Partner

    Joined:
    May 16, 2006
    Messages:
    4,437
    In 3.x the amprotect plugin (3rd party plugin from Ken Gary) can be used on multiple wordpress installations on the same server- hooking into the same amember.

    Ken is no longer selling the plugins, so you will need to contact someone with a developers license (like myself) to have it installed as part of a consulting package.

    David
  7. slinky

    slinky Member

    Joined:
    Jul 15, 2010
    Messages:
    200
    Thanks David. While I appreciate the offer, I am going to eventually move to V4. It would seem that for me a supported solution would be more appropriate for me and I can handle it more easily with stock install than a custom plugin.
  8. alex

    alex aMember Pro Customer Staff Member

    Joined:
    Jan 24, 2004
    Messages:
    6,021
    I believe this may be gracefully handled with a kind of OpenID server provided by aMember. I believe there are OpenId plugins available for Wordpress.
    This way user will be redirected to your main aMember installation to login, and then user will be automatically redirected to slave website, already logged-in.
    Could this solution work for you?
  9. slinky

    slinky Member

    Joined:
    Jul 15, 2010
    Messages:
    200
    Alex - None of the redirection is too important. I've had all kinds of trouble with login integration for each site, cookies, status, etc. especially with putting sessionstart at the top of the page. Easiest thing for me is a common registration and then you land on the "take me page" where you can go to any site we have manually. No need to automatically be taken back to that site.

    The other question I have is whether you can take registrations not through amember. Having a challenging time now figuring out how to accomplish another task - adding in some extra fields to link with other scripts like wordpress, e.g. your facebook page. User comes to amember, enters their page into a field and that field gets placed into the wordpress database.
  10. alex

    alex aMember Pro Customer Staff Member

    Joined:
    Jan 24, 2004
    Messages:
    6,021
    So as I understand OpenId could work for your case? We will work on this in January.

    Regarding a field - that is not hard to implement. Give our contacts to your PHP programmer and we will give a suggestion. It is literally several lines of code.
  11. slinky

    slinky Member

    Joined:
    Jul 15, 2010
    Messages:
    200
    Just wanted to make sure I'm doing this properly - there are a couple of items that seem to need be changed. You've got class names such as:

    Am_Protect_Wordpress_Table extends Am_Protect_Table

    I assume that might need to be changed to Am_Protect_Wordpress123_Table extends Am_Protect_Table so that the classes are unique and won't cause problems with calls to it.

    Next you have variables that seem to relate to folders, which would also seem to require renaming:

    protect.wordpress123.default_wplevel

    This way the proper path would be maintained - if it's talking about paths - I'm not quite sure. I don't know what that variable is referencing. Then again, if the calls are to member functions and variables stored than the unique name of the class should be enough...
  12. slinky

    slinky Member

    Joined:
    Jul 15, 2010
    Messages:
    200
    OK, so I didn't do the protect.wordpress123 and just the class functions. The additional wordpress plugin shows up as wordpress_123 and it does allow me to select it. But there is no button in the top area (like vbulletin and the rest) that shows nor the ability to select a database to connect - it's only in the "Integration Plugins" dropdown list. What am I missing here?
  13. slinky

    slinky Member

    Joined:
    Jul 15, 2010
    Messages:
    200
    Nailed it - I see. You're naming the entire function using the class name and just stripping the rest to create the title. Splendid. :)
  14. slinky

    slinky Member

    Joined:
    Jul 15, 2010
    Messages:
    200
    Bummer - doesn't work - it works until you actually install the Wordpress plugin

    Fatal error: Cannot redeclare class WordpressAPI in /home/mysite/public_html/amember/application/default/plugins/protect/wordpress/api.php on line 2
  15. alexander

    alexander Administrator Staff Member

    Joined:
    Jan 8, 2003
    Messages:
    6,279
    Plugin include api.php at the top of wordpress.php
    So, just modify code a little in all wordpress.php files so it will nto be duplicated, for example:
    PHP:
    if(!defined("WORDPRESS_API")){
    include_once(
    "api.php");
    define("WORDPRESS_API"1);
    }
  16. nbgmed

    nbgmed Member

    Joined:
    Sep 13, 2011
    Messages:
    35
    What are the exact steps for this particular method? I think it could be very helpful for us all. Most users have more than one membership up and running. ;-)
  17. alexander

    alexander Administrator Staff Member

    Joined:
    Jan 8, 2003
    Messages:
    6,279
    Do you mean you have two wordpress blogs that should be integrated into aMember? or two different products that should have different access permissions in one wordpress installation?
  18. nbgmed

    nbgmed Member

    Joined:
    Sep 13, 2011
    Messages:
    35
    Yes, 3 wordpress blogs must be integrated.

Share This Page