If/Then statement in v4 for loged in user

Discussion in 'aMember Pro v.4' started by stevenjohn, Mar 13, 2012.

  1. stevenjohn

    stevenjohn Member

    Joined:
    Nov 9, 2006
    Messages:
    40
    Hi there,

    I am looking to insert some code into layout.phtml that says:

    IF user is logged in then display "xyz", else do nothing

    I have seen in the forums reference to using smarty code, but thats v3 stuff.

    Can anyone help me with the php to work out if a user is logged in or not?

    Many thanks, Steve
  2. davidm1

    davidm1 aMember User & Partner

    Joined:
    May 16, 2006
    Messages:
    4,437
    Maybe something like this? (in the _top.phtml file it uses this)
    <?php if ($user) : ?>
    display
    <?php endif; ?>

    David
  3. stevenjohn

    stevenjohn Member

    Joined:
    Nov 9, 2006
    Messages:
    40
    Perfect! :)

    Many thanks David.
  4. stevenjohn

    stevenjohn Member

    Joined:
    Nov 9, 2006
    Messages:
    40
    Hi there,

    This code works - but not for all pages in the amember system.

    It works correctly for:

    • Main member page
    • Payments history
    • Edit profile
    But doesnt not display or work for pages:
    • Add/renew subscriptions
    • Helpdesk
    Any reasons why
    <?php if ($user) : ?> wouldnt work on these two pages, given it is fine on the other three pages??​
    Appreciate anyones input.​
    Kind regards, Steve.​

Share This Page