Placing user info on pages

Discussion in 'Templates customization' started by jcrewguy24, Oct 29, 2007.

  1. jcrewguy24

    jcrewguy24 aMember Pro Customer

    Joined:
    Oct 21, 2007
    Messages:
    27
    I found the information on this but have lost it now. How can we display the username "login name" of a customer on a page in our protected folders?
  2. davidm1

    davidm1 aMember User & Partner

    Joined:
    May 16, 2006
    Messages:
    4,437
    Are you talking about within aMember pages, or other pages on your site?

    For aMember pages you use:
    First Name:
    {$smarty.session._amember_user.name_f}


    David
  3. jcrewguy24

    jcrewguy24 aMember Pro Customer

    Joined:
    Oct 21, 2007
    Messages:
    27
    This would be for another page that isn't a template of amember.

    Thanks! :)
  4. alexander

    alexander Administrator Staff Member

    Joined:
    Jan 8, 2003
    Messages:
    6,279
  5. jcrewguy24

    jcrewguy24 aMember Pro Customer

    Joined:
    Oct 21, 2007
    Messages:
    27
    That's the page I was looking for. Thanks Alex!

    -Chris
  6. jcrewguy24

    jcrewguy24 aMember Pro Customer

    Joined:
    Oct 21, 2007
    Messages:
    27
    So I added This
    Code:
     <?php session_start(); ?>
    to the top of my html page and this
    Code:
    <?php
    print "$_SESSION['_amember_user']['login']"; ?>
    in the middle.

    It made my page completely blank when loaded...my apache is set up to process php in html files and works great except when I add the second snippet of code.

    What gives?
  7. alexander

    alexander Administrator Staff Member

    Joined:
    Jan 8, 2003
    Messages:
    6,279
    Do you have access to your php.ini?
    change php.ini setting display_errors to On
    Restart apache then test again and copy/paste error that you got.
  8. jcrewguy24

    jcrewguy24 aMember Pro Customer

    Joined:
    Oct 21, 2007
    Messages:
    27
    So after I enabled the php errors I saw and fixed the issue. Working on my new site, i get this printed on the web pages instead of the data itself.

    Array[name_f] [name_l]

    here is what my code looks like...

    Top of page:
    Code:
     <?php session_start(); ?> 
    In the body:
    Code:
     <?php print "$_SESSION[_amember_user][name_f] [name_l]"; ?> 
    The code is stuck between <div> tags....would this matter? How would I fix the issue?
  9. alexander

    alexander Administrator Staff Member

    Joined:
    Jan 8, 2003
    Messages:
    6,279
    This is not correct syntax.
    use this:
    Code:
    <?php print $_SESSION['_amember_user']['name_f']." ".$_SESSION['_amember_user']['name_l']; ?>
    
  10. jcrewguy24

    jcrewguy24 aMember Pro Customer

    Joined:
    Oct 21, 2007
    Messages:
    27
    Thanks...:)

    Next question,

    I noticed that [_amember_user] is linked to the mysql table 'amember_members'

    If I wanted to pull data from other tables within the amember database, where and how would I link to those tables?

    Thanks,

    Chris
  11. alexander

    alexander Administrator Staff Member

    Joined:
    Jan 8, 2003
    Messages:
    6,279
    This depends what data and where exactly you need it.

    By default aMember set these session variables:
    $_SESSION['_amember_user']
    $_SESSION['_amember_product_ids']
    $_SESSION['_amember_products']
    $_SESSION['_amember_subscriptions']
  12. jcrewguy24

    jcrewguy24 aMember Pro Customer

    Joined:
    Oct 21, 2007
    Messages:
    27
    how can I load additional tables?
  13. youjoomla

    youjoomla Member

    Joined:
    May 15, 2007
    Messages:
    61
    $_SESSION['_amember_user.TABLE_NAME']
  14. skippybosco

    skippybosco CGI-Central Partner Staff Member

    Joined:
    Aug 22, 2006
    Messages:
    2,526
    I would like to display, on a PHP file, the list of products a user has subscribed to.

    I would like for each product name to be a hyperlink to the product URL.

    Basically looking for identical behavior to what you see on the member.php page.

    Any suggestions?
  15. skippybosco

    skippybosco CGI-Central Partner Staff Member

    Joined:
    Aug 22, 2006
    Messages:
    2,526
    This works to get the products the user is subscribed to, hperlinked to the product URL:

    Code:
    <?
    foreach ($_SESSION['_amember_products'] as $p){
    print "<a href='".$p['url']."'>".$p['title']."</a><br />";
    }
    ?>
    

Share This Page