Using $_SESSION['_amember_user']

Discussion in 'aMember Pro v.4' started by quirk, Jan 18, 2012.

  1. quirk

    quirk Member

    Joined:
    Apr 1, 2011
    Messages:
    76
    In V3 I could use the member's credentials to personalise the pages they had subscribed to by putting

    PHP:
    session_start();
    $user $_SESSION['_amember_user'];
    then echo "($user[name_f])" would add their first name anywhere I wanted.

    How do I do this with V4?

    Thanks
  2. quirk

    quirk Member

    Joined:
    Apr 1, 2011
    Messages:
    76
    Sorry for bumping but I really to need an answer on this....
    If it's not possible I suppose I could go the old fashioned sql $query route...?!
  3. alexander

    alexander Administrator Staff Member

    Joined:
    Jan 8, 2003
    Messages:
    6,279
  4. quirk

    quirk Member

    Joined:
    Apr 1, 2011
    Messages:
    76
    Thanks, two further questions

    1. If I use
    Am_Lite::getInstance()->getUsername() how do I echo Username?
    2. How do I get name_f and user_id from table am_user and use them?

    Ta
  5. alexander

    alexander Administrator Staff Member

    Joined:
    Jan 8, 2003
    Messages:
    6,279
    1:
    PHP:
    <?php echo Am_Lite::getInstance()->getUsername(); ?>
    2.user_id is not available, why you need this?
    name:
    PHP:
    <?php echo Am_Lite::getInstance()->getName(); ?>
  6. quirk

    quirk Member

    Joined:
    Apr 1, 2011
    Messages:
    76
    Code:
    <?php echo Am_Lite::getInstance()->getName(); ?>
    
    Is this getting just the first name?

    I need the user_id for other sql records that are created when a new user signs up.

    And finally how do I store the Name variable as something easier to use please?
    like
    $MemberName = 'Am_Lite::getInstance()->getName()'; ?????
  7. alexander

    alexander Administrator Staff Member

    Joined:
    Jan 8, 2003
    Messages:
    6,279
    No. For first name you can use:
    PHP:
    <?php
    $user 
    =Am_Lite::getInstance()->getUser();
    echo 
    $user['name_f'];
    ?>
    PHP:
    <?php
    $user 
    =Am_Lite::getInstance()->getUser();
    echo 
    $user['user_id'];
    ?>
    See above
  8. quirk

    quirk Member

    Joined:
    Apr 1, 2011
    Messages:
    76
    Thank you

Share This Page