Front End Login Form

So many times clients (and their members) want to login on the front end. Simple to add this in the header, or sidebar. Style as you wish.

Put this in your header template (or anywhere else you want the form to appear.)

<?php if (!is_user_logged_in()) { ?>
	<form action="<?php echo get_option('home'); ?>/wp-login.php" method="post">
	<input type="text" name="log" id="log" value="<?php if (isset($user_login)) echo esc_html(stripslashes($user_login), 1) ?>" size="20" />
	<input type="password" name="pwd" id="pwd" size="20" />
	<input type="submit" name="submit" value="Login" />
	<input name="rememberme" id="rememberme" type="hidden" checked="checked" value="forever" />
	<input type="hidden" name="redirect_to" value="<?php echo home_url(); ?>" />
	<a href="<?php echo wp_lostpassword_url( home_url() ); ?>">Forgot password or username?</a>
	</form>
<?php } else { 
	global $current_user;
	get_currentuserinfo(); ?>				
	<p>Welcome, <?php if($current_user->user_firstname) echo $current_user->user_firstname; else echo $current_user->display_name; ?>!</p>
	<a class="button" href="<?php echo wp_logout_url( home_url() ); ?>">Logout</a>
<?php } ?>

 

Comments are closed.

Skip to toolbar