suggestions for next amember update to make it play nice with wordpress

Discussion in 'Integration' started by andyb, Aug 4, 2010.

  1. andyb

    andyb Member

    Joined:
    Jul 10, 2010
    Messages:
    41
    I have successfully integrated amember with wordpress 3.0 multi site and buddypress and can show the amember member page and tabs within the wordpress theme of whatever subdomain the user is viewing.

    I've also got functions working from wordpress in my site.inc.php file for amember so I can use things like $wpdb or functions like username_exists() or wp_insert_user()

    I was able to do this by including wp-config.php in site.inc.php but only after making a minor edit to the wordpress core file decprecated.php in wp-includes/ and the phpMailer.class in amember

    the function that causes a clash with amember is validate_email() which I renamed to svalidate_email() in deprecated.php

    and in amember/includes/phpmailer/class.phpmailer.php I wrapped the class in

    if(!class_exists('PHPMailer')){}

    Once these were done, I was able to use any wordpress function and incorporate the amember pages into my theme.

    I would like to request that the next version of amember renames or checks if the validate_email() function exists before declaring it. Also, to wrap the class in class.phpmailer.php with a if(!class_exists

    this would make it much much easier for people to use wordpress functions like username_exists() or wp_create_user() by including wp-config.php in their custom integration plugins.

    What I'm doing now works really well but I'll have to make sure I edit the deprecated.php file any time I update wordpress and also the class.phpmailer.php file whenever amember gets updated

    if these small updates were made to amember then hooks like validate_signup_form or finish_waiting_payment could use wordpress native functions without having to use the complicated xml rpc library or manually inserting rows to the wp database.

    would this be possible?
  2. alexander

    alexander Administrator Staff Member

    Joined:
    Jan 8, 2003
    Messages:
    6,279
    Thanks for suggestions I will implement these changes to aMember.
  3. andyb

    andyb Member

    Joined:
    Jul 10, 2010
    Messages:
    41
    great! thanks a lot. Looking forward to seeing the changes, let me know if you need me to beta test any changes on my local install.
  4. kengary

    kengary aMember Pro Customer

    Joined:
    Nov 13, 2008
    Messages:
    231
    Hey andyb!

    Could you walk us through exactly what your site.inc.php file looks like and how exactly you're integrating the aMember pages with your WordPress theme?

    I'd love a quick tutorial so I can compare it to how I normally do it and see if it's better/easier.

    Thanks!
  5. miso

    miso aMember Pro Customer

    Joined:
    Aug 22, 2006
    Messages:
    543
    Wow, that's... brilliant. It's a step up from my method of editing config.inc.php file, plus it somehow works just fine with Wordpress 3.0 (my method resulted in some minor issues with access to admin and such).

    Thanks for the heads up... this makes integrating Wordpress even less complicated. DAMN!
  6. andyb

    andyb Member

    Joined:
    Jul 10, 2010
    Messages:
    41
    I sure will, I have just got the latest beta of amember and it looks like Alex and team have changed the validate email function name and also wrapped the phpmailer class in a if(!class_exists block so it should make it even easier to integrate wp with amember.

    I'll do some testing with the beta and post a new thread with the tutorial aftewards (and when I get some time off work!)

    thanks! it was seeing what you did with the woothemes login that got me trying to get it all to work together.

    My way means I don't have to edit config.inc.php and can log the user in to amember member pages automagically if the user is already logged in to wordpress. It keeps the wordpress side smoother if the user only has to see the amember pages to signup or update a subscription.

    I need to use a custom amember plugin for amember->wordpress integration (for the amember plugin hooks like finish_waiting_payment etc) and also one for WP which does the wordpress->amember integration (for lost password routine and profile update) which keeps both databases in sync.

    I need the WP plugin so it all works the other way around like if the user logs in to amember first but, it's not too complex and lets me forget about using roles and capabilities to decide if a user has access or not because I can just use a key in the usermeta table which can be added to or taken away with update_user_meta in the integration plugin and then just check for that key with get_user_meta in any themes or plugins that I've decided are premium and need a live amember subscription.

    It's all working very nicely! I'll get around to putting a tutorial up after the weekend holiday.

    Andy
  7. kengary

    kengary aMember Pro Customer

    Joined:
    Nov 13, 2008
    Messages:
    231
    @andyb, did you get any further on making a tutorial to do this with 3.2.3?

    When I include the wp-config.php file in my site.inc.php it seems that the session variables are all gone.

    It won't remember the admin login and it won't remember a user login or the terms of service during signup, etc.

    Just wondering if this is still working with you.
  8. andyb

    andyb Member

    Joined:
    Jul 10, 2010
    Messages:
    41
    sorry Kengary, I got sidetracked trying to get post affiliate pro to work.

    the amember integration is indeed still working for me. I still haven't got around to writing the tutorial. sorry!

    when I had this problem it was because wordpress was saving cookies to a different domain value than amember.
    I had to set my php.ini to use .domain.com as the session cookie domain because wordpress would save to .domain.com and amember would save to domain.com (no leading dot)

    check with firecookie for firebug on firefox to see where your PHPSESSID is being saved to.

    you can edit php.ini or use ini_set in php code or add it to your .htaccess if your server allows it.

Share This Page