Ready to get started?Download WordPress


Conditional logged in/logged out info display (3 posts)

  1. sbstaskiewicz1
    Posted 8 years ago #

    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?


  2. dotnature
    Posted 8 years ago #

    you need to add a conditional statement , something like

    global $user_login, $user_nickname ;
    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

  3. sbstaskiewicz1
    Posted 8 years ago #

    Here's what I have coded:

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

    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>


    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?

Topic Closed

This topic has been closed to new replies.

About this Topic