treehouse : what would you like to learn today?
Web Design Web Development iOS Development

WP login/logged in display

  • Ok so I want to have a login form on front page that reloads the front page with a logged in box that displays info.
    I've got it all set up and ready to go... but I found out the code I'm using is for wp 1.5!
    I found it from an article here: http://www.wpdesigner.com/2007/07/09/how-to-place-a-login-form-in-the-sidebar/.

    Also, I can't get the current user's gravatar to show up correctly ( I don't need it linked).

    Help!

    <?php global $user_ID, $user_identity, $user_level ?>
    <?php if ( $user_ID ) : ?>
    <div id=\"loggedin-title\">Logged In</div>
    <div id=\"loggedin\">
    <?php echo get_avatar( $id_or_email, $size = '80', $default = '<path_to_url>' ); ?>
    <h4><?php echo $user_identity ?></h4>
    <ul id=\"list\">
    <li><a href=\"<?php bloginfo('url') ?>/wp-admin/\">Dashboard</a></li>
    <?php if ( $user_level >= 1 ) : ?>
    <li><a href=\"<?php bloginfo('url') ?>/wp-admin/post-new.php\">Write an article</a></li>
    <?php endif // $user_level >= 1 ?>
    <li><a href=\"<?php bloginfo('url') ?>/wp-login.php?action=logout&amp;redirect_to=<?php echo urlencode($_SERVER['REQUEST_URI']) ?>\">Exit</a></li>
    </ul>
    <div style=\"clear:both;\"></div>
    </div>
    <div id=\"loggedin-bottom\"></div>

    <?php elseif ( get_option('users_can_register') ) : ?>

    <form action=\"<?php bloginfo('url') ?>/wp-login.php\" method=\"post\" id=\"login-form\">
    <h3>Login</h3><p>
    <input type=\"text\" name=\"log\" id=\"username\" size=\"22\" value=\"<?php echo wp_specialchars(stripslashes($user_login), 1) ?>\" /><br />
    <input type=\"password\" name=\"pwd\" id=\"password\" size=\"22\" /><br />
    <input type=\"submit\" name=\"submit\" value=\"Send\" id=\"login-button\"/>
    </p>
    <input type=\"hidden\" name=\"redirect_to\" value=\"<?php echo $_SERVER['REQUEST_URI']; ?>\" />
    </form>
    <?php endif // get_option('users_can_register') ?>
  • I feel like I should be using this:
    http://codex.wordpress.org/Function_Reference/get_currentuserinfo