How To Redirect WordPress Login/Logout to Amember Login Page

Discussion in 'Installation' started by ericdarby, Aug 27, 2009.

  1. ericdarby

    ericdarby New Member

    Joined:
    Aug 27, 2009
    Messages:
    2
    This thread concerns logging in and out of a Wordpress blog and integrating this process with amember login / logout.

    First thing to know is that only certain pages of my blog are protected by amember. The rest is public. So, in amember-speak, my entire blog is not protected behind a folder

    1) What I want to do is redirect anyone to my AMEMBER login page who tries to use the standard WORDPRESS login page. (I dont want them to see this Wordpress login page at all.)

    2) When a subscriber tries to logout of my blog using those standard Wordpress logout links at the bottom of each blog post, I want two things to happen:
    a. The person should logout of AMEMBER also (this does not happen now. I asked support about this.)
    b. The person should be redirected to the page of my choosing - ie. my blog home page. Again, I don't want them to see the Wordpress login / logout page at all.

    Not sure if this is possible. I just want to make the whole thing a seemless experience for my subscribers and avoid any multiple login page confusion.

    Thanks in advance for any tips on this.

    - Eric Darby
  2. erwinvdb

    erwinvdb aMember Pro Customer

    Joined:
    Aug 30, 2007
    Messages:
    264
    Did you find a solution for this yet? I'd like to know how to fix this too :)
  3. erwinvdb

    erwinvdb aMember Pro Customer

    Joined:
    Aug 30, 2007
    Messages:
    264
    Ok, I think I have the first part of MY problem (how to return them to the page where they came from) solved:
    add these line to your .htaccess file:
    Code:
    RewriteCond %{QUERY_STRING} ^redirect_to=(.*)
    RewriteRule ^wp-login.php$ /amember/login.php?amember_redirect_url=%1 [NE,R=301,L]
    Regarding your problem Eric, for #1 the following will work:
    Code:
    RewriteRule ^wp-login.php$ /amember/login.php [R=301,L]
    Now, there's also a wp-register.php and we want them to go the signup page:
    Code:
    RewriteCond %{QUERY_STRING} ^action=register$
    RewriteRule ^wp-login.php$ /amember/signup.php? [R=301,L]
    Ok, now for the final part: logout.
    Code:
    RewriteCond %{QUERY_STRING} ^action=logout
    RewriteRule ^wp-login.php$ /amember/logout.php? [R=301,L]
    
    For everything to work correctly you NEED to put the 'plain' wp-login rewrite last! So putting it all together you'll get:
    Code:
    RewriteCond %{QUERY_STRING} ^action=register$
    RewriteRule ^wp-login.php$ /amember/signup.php? [R=301,L]
    RewriteCond %{QUERY_STRING} ^action=logout
    RewriteRule ^wp-login.php$ /amember/logout.php? [R=301,L]
    RewriteCond %{QUERY_STRING} ^redirect_to=(.*)
    RewriteRule ^wp-login.php$ /amember/login.php?amember_redirect_url=%1 [NE,R=301,L]
    RewriteRule ^wp-login.php$ /amember/login.php [R=301,L]
    Regarding your point 2b: you can set that value in
    aMember Control Panel > Setup/Configuration > PHP Include > Redirect after logout
    (if you can't find PHP include in the top row items, make sure you enable it in the plugin section)

    Regards,
    Erwin

    P.S. I love to get feedback from (htaccess) gurus on how to improve the above ;)
  4. superlativesmagazine

    superlativesmagazine New Member

    Joined:
    Jan 18, 2010
    Messages:
    5
    I'm hesitant to propose an alternative solution, because I'm such a novice at all this. But, on my wordpress site, I was able to solved this problem more simply.

    All I did was change the wordpress php file that contains my footer. I located the wordpress logout link in the footer php and changed it to the amember logout link -- yoursite.com/amember/logout.php.

    It works beautifully, even logs out the wordpress admin for my site, who at this time, isn't a registered amember user.

    I hope that helps.
  5. erwinvdb

    erwinvdb aMember Pro Customer

    Joined:
    Aug 30, 2007
    Messages:
    264
    Did changing the links in the footer also result in changes of the links that are shown above the comment section? E.g. "you have to be logged on to leave a comment"?
  6. dale_s

    dale_s aMember Pro Customer

    Joined:
    Apr 12, 2013
    Messages:
    96
    I applied the first two parts of the code provided and got a 404 error message with this in the url field:

    /www.mysite.com/members/login.php?amember_redirect_url=/my-protected-page-url/

    Maybe it's because this is a couple years old?

    Anyone know the current way to redirect a member from the WordPress login page to the aMember login, and then back to the WordPress page they were trying to first access (once they login)?

    Thanks for any help.
  7. dale_s

    dale_s aMember Pro Customer

    Joined:
    Apr 12, 2013
    Messages:
    96
    I got it to work on one test site I have set up - but this brings up a question. If all logins are redirected to aMember, how do you login as admin to WordPress (without getting redirected). Maybe it's a stupid question, but I can't figure it out. Thanks for any help.
  8. alexander

    alexander Administrator Staff Member

    Joined:
    Jan 8, 2003
    Messages:
    6,279
    You need to add "admin" product to aMember and assign it to administrator group in wordpress.
    Then add your wordpress admin user to aMember and add lifetime subscription to admin product in wordpress.
    In wordpress plugin configuration, remove all groups from Admin groups setting.
    This way you will be able to login into aMember with your wordpress admin login/password and be logged in wordpress at the same time.
  9. dale_s

    dale_s aMember Pro Customer

    Joined:
    Apr 12, 2013
    Messages:
    96
  10. alexander

    alexander Administrator Staff Member

    Joined:
    Jan 8, 2003
    Messages:
    6,279
    I send rely in helpdesk, will copy in this thread as well :
    I believe on other site you are using old style urls from amember v3.
    aMember v4 still support these urls but you have to enable this in aMember CP -> Setup -> Advanced -> use v3 urls.
    I have enabled this on your install so url should work now.

Share This Page