Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.