Admin Area

How To Customise The WordPress Login Page

In this tutorial we are going to look at the WordPress login page, with WordPress you can customise anything you want and this includes the built in WordPress login page.

I have previously wrote snippets on how you can do different things such as:

We are going to bring all these together and how you can add your own CSS to customise the login page and plugins you can use to customise your login page.

The reason you would want to customise the WordPress built in login page is so you can add a bit more customisation to your clients websites.

You can even add your own branding to this page so your clients will see your logo each time they go to your login page.

Change Login Page URL

To get to the WordPress login page you need to navigate to the, but if your end user doesn't do much web work they might forget or get confused when entering wp-login.php.

It's up to you, the developer to make it as easy as possible for the end user to get to the login page.

You can change the URL they use to get to login page by adding the following into your htaccess file.

RewriteRule ^login$ [NC,L]

This allows the user to navigate to and they will be redirected to your login page.

Remove Lost Password Link

Wordpress reset password If someone has hacked your email account they will be able to get your WordPress password and shut down your site completely.

Below is a WordPress snippet that allows you to remove the lost your password text from the login screen, just add the following in your functions.php file.

function remove_lostpassword_text ( $text ) {
     if ($text == 'Lost your password?'){$text = '';}
        return $text;
add_filter( 'gettext', 'remove_lostpassword_text' );

Change Login Page Logo

Here is the snippet to change the logo on the login screen.

All you have to do is copy this code into your functions.php file and change the image to the image you want to use and it's done.

function custom_login_logo() {
    echo '<style type="text/css">
        h1 a { background-image:url('. get_bloginfo( 'template_directory' ) .'/images/logo.jpg) !important; }

add_action('login_head', 'custom_login_logo');

Change Login Logo Link URL

The default logo link will point to the site, you can change this and point it to your own blog site by using the following snippet.

function my_login_logo_url() {
    return get_bloginfo( 'url' );
add_filter( 'login_headerurl', 'my_login_logo_url' );

function my_login_logo_url_title() {
    return 'Your Site Name and Info';
add_filter( 'login_headertitle', 'my_login_logo_url_title' );

The above changes the logo link to your blog url and will change the title of the link to anything you want.

Hide Error Messages

On the WordPress login page if you type in an incorrect username or password it will return an error message to say that your username or password was incorrect.

The below picture lets me know that the username I am using doesn't exist and I need to try something else.

But if the username does exist and I just get the password wrong WordPress will display this message.

Now I know that there is a user called admin and I can keep trying this until I get the password right.

Yes, this is a very helpful message for real users of the site as they can see what has gone through. But for hackers this means they get a nice message on they have got wrong, meaning they will also know what they have got right.

There is a login page hook to access to remove any error message from the login page.

Copy the following in your functions.php file.

add_filter('login_errors',create_function('$a', "return null;"));

Login With Email Address

The following code snippet will make it so your users can login with their email address instead of the username, good if users are forgetting their username.

add_action( 'wp_authenticate', 'email_address_login' );

function email_address_login( &$username, &$password )
    $user = get_user_by( 'email', $username );

    if( !empty( $user->user_login ) )
        $username = $user->user_login;

Change Redirect URL

By default when you login to WordPress admin area it will take you to your domain /wp-admin/ which is the dashboard of the admin area.

But if you want change the location of this redirect WordPress has a filter called login_redirect to change the URL WordPress will redirect you to once you login.

Using the following code you can make sure that only admin users are allowed into your admin area and all other users will be redirected to your site home page.

function admin_login_redirect( $redirect_to, $request, $user )
    global $user;
    if( isset( $user->roles ) && is_array( $user->roles ) ) {
        if( in_array( "administrator", $user->roles ) ) {
            return $redirect_to;
        } else {
            return home_url();
        return $redirect_to;
add_filter("login_redirect", "admin_login_redirect", 10, 3);

Remove Login Page Error Shake

When a remove types in an incorrect username or password WordPress will display a error message on the page. It will alert the user of the incorrect username or password by shaking the screen.

Some people don't like this feature as it can be quite annoying, to remove the shake from being ran you can use the following function.

Just add this to your functions.php to remove an action from the login head.

function my_login_head() {
	remove_action('login_head', 'wp_shake_js', 12);
add_action('login_head', 'my_login_head');

Display A Custom Message

You can display your own custom message on the login form by using the WordPress action register_form. This message can say anything that you want but most people use this to display custom instructions on any requirements when logging in to the WordPress admin.

Use the following snippet to add your message on the login page.

add_action('register_form', 'login_form_message');
function login_form_message() {
    echo '<p>Custom Login Form Message</p>';

Set Remember Me To Be Checked

By default the checkbox is always unchecked, so you have to select it each time. I prefer this to checkbox to be selected each time so I don't have to keep clicking on the login page.

Here is a snippet you can add to your functions.php file which will make sure that the checkbox is always checked when you go to the login page.

function login_checked_remember_me() {
	add_filter( 'login_footer', 'rememberme_checked' );
add_action( 'init', 'login_checked_remember_me' );

function rememberme_checked() {
	echo "<script>document.getElementById('rememberme').checked = true;</script>";

Add Custom CSS

Changing the WordPress logo on the login page isn't the only thing you can do with the CSS on the login page. You can actually overwrite all the CSS on the page by adding your own CSS file to the page.

You can add CSS to the page by using the login action login_enqueue_scripts.

Use the below snippet to add extra CSS to the page.

function my_login_stylesheet() 
    wp_enqueue_style( 'login-head', 'style-login.css', false );
add_action( 'login_enqueue_scripts', 'my_login_stylesheet' );

Login Page CSS Selectors

To be able to change all of the styles on the login page you need to know what CSS selectors you can use. Below are all the selectors you can change on the login page.

body.login {}
body.login div#login {}
body.login div#login h1 {}
body.login div#login h1 a {}
body.login div#login form#loginform {}
body.login div#login form#loginform p {}
body.login div#login form#loginform p label {}
body.login div#login form#loginform input {}
body.login div#login form#loginform input#user_login {}
body.login div#login form#loginform input#user_pass {}
body.login div#login form#loginform p.forgetmenot {}
body.login div#login form#loginform p.forgetmenot input#rememberme {}
body.login div#login form#loginform p.submit {}
body.login div#login form#loginform p.submit input#wp-submit {}
body.login div#login p#nav {}
body.login div#login p#nav a {}
body.login div#login p#backtoblog {}
body.login div#login p#backtoblog a {}

Login Page Hooks

With WordPress you use hooks and filters to add your own functionality to existing WordPress functions. The login page is no different, in the head of the page there are two actions, login_enqueue_scripts and login_head.

The actions at the bottom of the page are login_form, login_footer.

There are filters in the body of the login form which allows you to change the content which is loaded. These filters are: login_headerurl, login_headertitle, login_message, login_errors.

Create Your Own WordPress Login Page

The default WordPress login form is normally used for admin users to login in to enter content, but WordPress can be used for so much more.

You can use it as an ecommerce website and allow customers to login in to your site before being able to buy something. If you are allowing your users to login to manage their account you don't want them to go to the default WordPress dashboard you want to create your own user dashboard.

As these are two different forms you need to be able to create a new form, if you want to manage the users from your WordPress dashboard then you can use the default WordPress login functionality on your own login form.

To create your own login form you need to use the WordPress function wp_login_form().

Login Form Arguments

There are a number of arguments you can pass to your login form to customise it as you want.

<?php $args = array(
        'echo' => true,         // To echo the form on the page
        'redirect' => site_url( $_SERVER['REQUEST_URI'] ),   // The URL you redirect logged in users
        'form_id' => 'loginform',                            // Id of the form
        'label_username' => __( 'Username' ),                // Label of username
        'label_password' => __( 'Password' ),                // Label of password
        'label_remember' => __( 'Remember Me' ),             // Label for remember me
        'label_log_in' => __( 'Log In' ),                    // Label for log in
        'id_username' => 'user_login',                       // Id on username textbox
        'id_password' => 'user_pass',                        // Id on password textbox
        'id_remember' => 'rememberme',                       // Id on rememberme textbox
        'id_submit' => 'wp-submit',                          // Id on submit button
        'remember' => true,                                  // Display remember me checkbox
        'value_username' => NULL,                            // Default username value
        'value_remember' => false );                         // Default rememberme checkbox

wp_login_form( $args );

Examples Of Login Pages

Customise Your Login Page Plugins

The above explained how you can customise the login page by editing the code but here are a number of different plugins you can use to customise your WordPress login form.

Login Ninja

  • protect login & register forms with captchatest
  • automatically ban IPs that brute-force attack you
  • detailed log of all login-related activities
  • redirect users based on roles and usernames
  • get email notifications for all login events
  • protect site from brute-force login attacks
  • stop bots from registering
  • manually ban any IP
  • native, easy to use WP GUI
  • detailed documentation

Buy Now For $15

Pathway - Custom WordPress Login Page

  • Custom Background color & image
  • Custom Form border & round & bg color & image
  • Custom Field border & round & bg color & etc
  • Custom Field Text color ( hover / active / focus)
  • Button color options
  • Custom Logo
  • Custom Copyright text color & hover
  • Shaker Effect Options
  • Extensice Admin Options (Unbranded!)
  • WordPress 3.0.+ Ready
  • Extensive Documentation

Buy Now For $12

Wp Nice Screen Login - Customize Admin Login Page

WP Nice Screen Login is the final solution to customize the “Wordpress Admin Login Page”. You can choose from 5 default themes to redesign the Login Page, and bring to your clients a new professional page to login.

Buy Now For $10

Back to top

Learn how to code with Treehouse

  • Learn projects with access to 1000+ videos
  • Practice live with our Code Challenge Engine
  • Get help in our members-only forums

Start with a 7 day free trial


  1. […] big thanks to Paul Underwood and his awesome snippets blog, which I’ve borrowed […]