Skip to content

Instantly share code, notes, and snippets.

@DevWael
Last active October 2, 2018 01:06
Show Gist options
  • Save DevWael/7b86c976cad40ffd10d49548f1af376c to your computer and use it in GitHub Desktop.
Save DevWael/7b86c976cad40ffd10d49548f1af376c to your computer and use it in GitHub Desktop.
WordPress Login/Out Form
<?php
function prefix_login_form( $login_only = 0 ) {
global $user_ID, $user_level, $user_identity;
$redirect = site_url();
if ( $user_ID ) : ?>
<?php if ( empty( $login_only ) ): ?>
<div class="user-login">
<div class="author-avatar"><?php echo get_avatar( $user_ID, $size = '80' ); ?></div>
<p class="welcome-text"><?php esc_html_e( 'Welcome', 'window-mag' ); ?>
<strong><?php echo $user_identity ?></strong> .</p>
<ul>
<li><a href="<?php echo admin_url() ?>"><?php esc_html_e( 'Dashboard', 'window-mag' ); ?> </a>
</li>
<li>
<a href="<?php echo admin_url() ?>profile.php"><?php esc_html_e( 'Your Profile', 'window-mag' ); ?> </a>
</li>
<li>
<a href="<?php echo wp_logout_url( $redirect ); ?>"><?php esc_html_e( 'Logout', 'window-mag' ); ?> </a>
</li>
</ul>
<div class="clearfix"></div>
</div>
<?php endif; ?>
<?php else: ?>
<div class="login-form">
<form name="loginform"
action="<?php echo esc_url( site_url( 'wp-login.php', 'login_post' ) ); ?>" method="post">
<p class="log-username">
<input type="text" name="log" class="log"
title="<?php esc_html_e( 'Username', 'window-mag' ); ?>"
placeholder="<?php esc_html_e( 'Username', 'window-mag' ); ?>"
size="33"/>
</p>
<p class="log-pass">
<input type="password" name="pwd" class="pwd"
title="<?php esc_html_e( 'Password', 'window-mag' ); ?>"
placeholder="<?php esc_html_e( 'Password', 'window-mag' ); ?>"
size="33"/>
</p>
<input type="submit" name="submit" value="<?php esc_html_e( 'Log in', 'window-mag' ) ?>"
class="login-button"/>
<label for="rememberme"><input name="rememberme" class="rememberme" type="checkbox"
checked="checked"
value="forever"/> <?php esc_html_e( 'Remember Me', 'window-mag' ); ?>
</label>
<input type="hidden" name="redirect_to" value="<?php echo $_SERVER['REQUEST_URI']; ?>"/>
</form>
<ul class="login-links">
<?php echo wp_register(); ?>
<li>
<a href="<?php echo wp_lostpassword_url( $redirect ) ?>"><?php esc_html_e( 'Lost your password?', 'window-mag' ); ?></a>
</li>
</ul>
</div>
<?php endif;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment