Frontend login
-
I have a good login for the frontend, but I’m having trouble getting it to recognize when the user is logged out/when no one is logged in.
Here’s the code:
<?php if ( $current_user ) : ?> <?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 global $user_ID, $user_identity, $user_level, $user_ID; global $current_user; get_currentuserinfo(); ?> <div id="loggedin-title">Logged In</div> <div id="loggedin"> <?php echo get_avatar( $current_user->ID, $size = '80' ); ?> <h4><?php echo $current_user->user_firstname; ?></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 a Post</a></li> <?php endif // $user_level >= 1 ?> <li><a href="<?php bloginfo('url') ?>/wp-login.php?action=logout&redirect_to=<?php echo urlencode($_SERVER['REQUEST_URI']) ?>">Exit</a></li> </ul> <div style="clear:both;"></div> </div> <div id="loggedin-bottom"></div> <?php endif //get_option('users_can_register') ?>
Any ideas?
I know that$user_ID
is an old tag and I’m not 100% sure how to useget_currentuserinfo
. I’m not sure if that matters.
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘Frontend login’ is closed to new replies.