How to Get the Username

Discussion in 'Integration' started by sarah101, Jun 2, 2008.

  1. sarah101

    sarah101 New Member

    Joined:
    Jul 1, 2007
    Messages:
    32
    Does anyone know how to get a user's username with a bit of php code? I need to display it on a menu bar.
  2. skippybosco

    skippybosco CGI-Central Partner Staff Member

    Joined:
    Aug 22, 2006
    Messages:
    2,526
    Retrieved from http://manual.amember.com/Integrating_aMember_Pro_with_website

  3. sarah101

    sarah101 New Member

    Joined:
    Jul 1, 2007
    Messages:
    32
    Works! Many thanks!
  4. allensamha

    allensamha New Member

    Joined:
    Jun 14, 2008
    Messages:
    6
    i did that in header.html.php and it's throwing this error:

    "SEVERITY: UNDEFINED index variable _amember_user"

    funny thing is ill logout then login and the username will appear instead of this error.
  5. davidm1

    davidm1 aMember User & Partner

    Joined:
    May 16, 2006
    Messages:
    4,437
    header.html.php... what file is this? One you wrote or an amember file?

    If you are using the amember file header.html you shouldnt be using the <?php> tags. Its smarty.
    Use {$smarty.session._amember_user.name_f}

    David
  6. allensamha

    allensamha New Member

    Joined:
    Jun 14, 2008
    Messages:
    6
    It's part of code igniter. This is the portion of code thats giving error:

    Code:
    <?php if ( !defined('AMEMBERINTEGRATION') || !AMEMBERINTEGRATION || !isset($isValidAmemberUser) || (isset($isValidAmemberUser) ? !$isValidAmemberUser : true) ) {?>
    
    <div id="login2">
    
    <span class="style8"><?php print "Welcome, " . $_SESSION['_amember_user']['name_f'] . " " . $_SESSION['_amember_user']['name_l'];
    ?>!&nbsp;&nbsp;</span>
    
    </div>
    
    <?php } else { ?>
    
    <div id="login">XXXX</div>
    
    <?php }?>
  7. jonnywales

    jonnywales New Member

    Joined:
    Oct 27, 2007
    Messages:
    11
    Code not working but may be my fault...

    I have a regular html coded page with a .php extension. I included the session start code at very top of page and then the "Welcome" code at start of body area.

    Only the word "Welcome," is showing, members ID or Name is not.

    Can this have something to do with the fact that after in have <?php session start ?> code at top of page I have HTML tag stc following it. Should I get rid of html tag?

    I'm not good at coding php though I use php extensions because of "include" codes I use.

    Any answers?

    Thanks

    John J.
  8. davidm1

    davidm1 aMember User & Partner

    Joined:
    May 16, 2006
    Messages:
    4,437
    Give this a try:
    session_save_path(dirname(__FILE__)."/amember/sess/");
    session_start();

    I think that sometimes the script session location and amembers are different.

    David

Share This Page