How to add "logged in as ...." to all the pages?

Discussion in 'Customization & add-ons' started by umitbatu, Sep 13, 2012.

  1. umitbatu

    umitbatu aMember Pro Customer

    Joined:
    Dec 16, 2011
    Messages:
    16
    I can detect if a user is logged in or not by

    $lite = Am_Lite::getInstance();
    if($lite->isLoggedIn()){
    ....}

    My question is how can I add a text "logged in as johndoe@example.com" to any page on the site.
  2. thehpmc

    thehpmc Member

    Joined:
    Aug 24, 2006
    Messages:
    901
    if the above code works have you tried inserting between the {} brackets

    echo 'Is logged in as '.Am_Lite::getInstance()->getUsername() ;

    Is the line of code in your post correct? I thought it should be:
    if(Am_Lite::getInstance()->isLoggedIn()){...}

    this would make your required code something like-

    if(Am_Lite::getInstance()->isLoggedIn()){
    echo 'Is logged in as '. Am_Lite::getInstance()->getUsername() ;
    }

    but haven't tried it. I will include some 'if logged in' code in my own site but haven't gotten around to it yet so haven't tried the above yet.
    umitbatu likes this.
  3. umitbatu

    umitbatu aMember Pro Customer

    Joined:
    Dec 16, 2011
    Messages:
    16
    i just used $lite variable, basically the code is the same.
    getEmail() instead of getUsername().
    The problem is solved it works.
    Thanks

Share This Page