Skip to content

Instantly share code, notes, and snippets.

@ahmadawais
Last active July 20, 2019 09:18
Show Gist options
  • Star 7 You must be signed in to star a gist
  • Fork 6 You must be signed in to fork a gist
  • Save ahmadawais/1c3332a4627e4db3a9ba to your computer and use it in GitHub Desktop.
Save ahmadawais/1c3332a4627e4db3a9ba to your computer and use it in GitHub Desktop.
WordPress Frontend Login Page [UPDATED]
<?php
/**
* Template Name: Login Page AA
*
* Login Page Template.
*
* @author Ahmad Awais
* @since 1.0.0
*/
get_header(); ?>
<!-- section -->
<section class="aa_loginForm">
<?php
global $user_login;
// In case of a login error.
if ( isset( $_GET['login'] ) && $_GET['login'] == 'failed' ) : ?>
<div class="aa_error">
<p><?php _e( 'FAILED: Try again!', 'AA' ); ?></p>
</div>
<?php
endif;
// If user is already logged in.
if ( is_user_logged_in() ) : ?>
<div class="aa_logout">
<?php
_e( 'Hello', 'AA' );
echo $user_login;
?>
</br>
<?php _e( 'You are already logged in.', 'AA' ); ?>
</div>
<a id="wp-submit" href="<?php echo wp_logout_url(); ?>" title="Logout">
<?php _e( 'Logout', 'AA' ); ?>
</a>
<?php
// If user is not logged in.
else:
// Login form arguments.
$args = array(
'echo' => true,
'redirect' => home_url( '/wp-admin/' ),
'form_id' => 'loginform',
'label_username' => __( 'Username' ),
'label_password' => __( 'Password' ),
'label_remember' => __( 'Remember Me' ),
'label_log_in' => __( 'Log In' ),
'id_username' => 'user_login',
'id_password' => 'user_pass',
'id_remember' => 'rememberme',
'id_submit' => 'wp-submit',
'remember' => true,
'value_username' => NULL,
'value_remember' => true
);
// Calling the login form.
wp_login_form( $args );
endif;
?>
</section>
<!-- /section -->
<?php get_footer(); ?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment