Custom Login Link Button

Discussion in 'aMember Pro v.4' started by jdsilva, Feb 1, 2013.

  1. jdsilva

    jdsilva New Member

    Joined:
    Jun 3, 2011
    Messages:
    7
    Does anyone know how I can change the aMember Login link in Wordpress to detect whether the user is logged in, and if so, allow them to click the link for 'my account' page.
  2. alexander

    alexander Administrator Staff Member

    Joined:
    Jan 8, 2003
    Messages:
    6,279
    You can use this code in wordpress template:
    PHP:
    if(am4PluginsManager::getAPI()->getUser())
    // User is logged in show account link
    }else{
    // User is not logged in show login link
    }
  3. gswaim

    gswaim CGI-Central Partner

    Joined:
    Jul 2, 2003
    Messages:
    641
    I have aMember links in my WordPress site that change based on the login status. I use two aMember text widgets in a sidebar on the homepage to do this.

    Here is a detailed video on how to do this. Sorry for the shameless self promotion, but this video was already produced and handy. It's a little long, but too much info is usually better than not enough :)
  4. wallpaper_01

    wallpaper_01 Member

    Joined:
    Mar 9, 2011
    Messages:
    116
    I'm looking for something similar to the above.

    At the moment I'm using:

    include "../amember/library/Am/Lite.php";
    echo Am_Lite::getInstance()->renderLoginForm();

    To get the login form in a widget in Joomla. Is there a way to show the users name after they are logged in? in place of the login form?

    Thanks
  5. alexander

    alexander Administrator Staff Member

    Joined:
    Jan 8, 2003
    Messages:
    6,279
    Use something like this:
    PHP:
    include "../amember/library/Am/Lite.php";
    if(
    $user Am_Lite::getInstance()->getUser()){
       echo 
    "Welcome ".$user['name_f']." ".$user['name_l']." !";
    }else
       echo 
    Am_Lite::getInstance()->renderLoginForm();
  6. wallpaper_01

    wallpaper_01 Member

    Joined:
    Mar 9, 2011
    Messages:
    116
    This works, as in it shows the login form but they are logged in in amember and it still shows the form. Are there some sort of session details that need to be passed over?
  7. alexander

    alexander Administrator Staff Member

    Joined:
    Jan 8, 2003
    Messages:
    6,279
    what you have in aMember CP -> Setup -> Advanced -> Session Storage?
  8. wallpaper_01

    wallpaper_01 Member

    Joined:
    Mar 9, 2011
    Messages:
    116
    Standard PHP Sessions Can't be changed because your server have suhosin extension enabled
  9. alexander

    alexander Administrator Staff Member

    Joined:
    Jan 8, 2003
    Messages:
    6,279
    This will not work unfortunately. You can get it working only when Session Storage Method is set to "database"
    Joomla use the same PHP sessions but change save_handler, and session_name so, there is no way to access aMember's session in this situation. If you would like to use login work the way explained above, disable suhosin extension in php and switch session storage in aMember to database.
  10. wallpaper_01

    wallpaper_01 Member

    Joined:
    Mar 9, 2011
    Messages:
    116
    I'm using nginx, with amember, efront and joomla. Turning off Suhosin, will it affect anything?
  11. alexander

    alexander Administrator Staff Member

    Joined:
    Jan 8, 2003
    Messages:
    6,279
    No I don't think that this will affect anything.
  12. wallpaper_01

    wallpaper_01 Member

    Joined:
    Mar 9, 2011
    Messages:
    116
    Yep cool, all works ok, is there anyway I can add some code to the script that refreshes the page? You have to manual click refresh to see the difference, I also put a logout link on it that works but doesnt refresh the joomla page to see the difference.
  13. alexander

    alexander Administrator Staff Member

    Joined:
    Jan 8, 2003
    Messages:
    6,279
    Do you display login form in frame? Or use ajax?
    It should redirect you to aMember and then redirect back, so page will be refreshed automatically.
  14. wallpaper_01

    wallpaper_01 Member

    Joined:
    Mar 9, 2011
    Messages:
    116
    Well I was using a plugin called Jumi. But stopped that and enabled the normal Joomla login form. This works better and does refresh but I want to redirect after login to the member area which is not working (there is an option to redirect in the module settings).

    I think the reason is that it is logging into amember then coming back to the home page of joomla by default so not redirecting. Is this something to do with the Joomla plugin I got from you guys?
  15. wallpaper_01

    wallpaper_01 Member

    Joined:
    Mar 9, 2011
    Messages:
    116
    Will figure it out

Share This Page