WordPress.org

Support

Support » Plugins and Hacks » Conditional logged in/logged out info display

Conditional logged in/logged out info display

  • I would like to display basic user info (user identity and post count) at the top of the sidebar. I only want this info to be displayed if the user is logged in.

    What is the proper way to code the conditional statement? WP has the ability built in to the wp_register and wp-loginout tags. Can I take advantage of this?

    TIA,
    Steve

Viewing 2 replies - 1 through 2 (of 2 total)
  • you need to add a conditional statement , something like

    <?php
    global $user_login, $user_nickname ;
    get_currentuserinfo();
    if ($user_login){
    echo '<a href="wp-login.php?action=logout">logout ' . $user_nickname . '</a>,

    <a href="wp-admin/profile.php">Profile</a>'

    ;
    }
    else {
    echo '<a href="wp-register.php">login/register</a>';
    }
    ?>

    this basically says if user is logged in do something or if he not do something else. This example shows logout/login link but you can just change that part

    Here’s what I have coded:

    <p class="post-footer">
    <?php global $user_identity;
    get_currentuserinfo();

    echo ('Welcome ' . $user_identity . '.');
    ?>
    <br />
    You have posted <?php the_author_posts(); ?> times.
    <br />
    <em><a href="wp-admin/profile.php">Edit your Profile.</a></em>
    </p>

    <ul><li</li></ul>

    If I add anything conditional, I get parsing errors up the wazoo. What is the best way to code the conditional statement in there without wrecking the whole thing?

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Conditional logged in/logged out info display’ is closed to new replies.