• Resolved cmoseley

    (@cmoseley)


    Is there a conditional tag or something that I can use to display a certain text if a user is logged in, and something else if a user is logged out in my template files?

Viewing 2 replies - 1 through 2 (of 2 total)
  • Moderator Samuel Wood (Otto)

    (@otto42)

    www.remarpro.com Admin

    The $user_ID global will be set for a logged on user, once get_currentuserinfo() has been called. However, this is actually always called at WP->init, so you don’t have to call it yourself.

    So in a theme, you can just do:

    if ($user_ID) {
    // logged on
    } else {
    // not logged on
    }

    There’s various other globals too. $user_identity is the nickname, etc. Look in the link above for some of the various globals available to you.

    For me, the $user_ID variable is empty even though I’m logged in. Any reasons why this might be occurring?

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Conditional Tag for Checking Login/Logout?’ is closed to new replies.