• Blog

    Latest from our Blog

  • Tools

    Our Favourite WP Tools

  • Hosting

    Recommended Web Hosts

  • Coupons

    Get great money off deals

  • Themes

    WordPress Theme Directory

  • Plugins

    WordPress Plugins Directory

  • Promote

    Your WordPress Product

If your site requires people to login and you’d like them to do it via your theme rather than the default WordPress login screen ( wp-login.php ) you can create a custom login page using a page template. In this tutorial I will walk you though how to create one.

Create the Page Template

Create a new file and name it “page-login.php” and add this code to the top of it, this identifies it to WordPress as a page template :

<?php
/*
Template Name: Login Page
*/
?>

Add your header and open Divs

You will need to add in your WordPress header tag and any divs you use in your layout, these are what I use on WPLift :

<?php get_header(); ?>

<div id="left">
<div id="archive">

The login form code

Next up, paste this code in which is the page title and the actual login form :

<h2><?php the_title(); ?></h2>

<form name="loginform" id="loginform" action="<?php echo get_option('home'); ?>/wp-login.php" method="post">
	<p>
		<label>Username<br />
		<input type="text" name="log" id="user_login" class="input" value="" size="20" tabindex="10" /></label>
	</p>
	<p>

		<label>Password<br />
		<input type="password" name="pwd" id="user_pass" class="input" value="" size="20" tabindex="20" /></label>
	</p>
	<p class="forgetmenot"><label><input name="rememberme" type="checkbox" id="rememberme" value="forever" tabindex="90" /> Remember Me</label></p>
	<p class="submit">
		<input type="submit" name="wp-submit" id="wp-submit" class="button-primary" value="Log In" tabindex="100" />
		<input type="hidden" name="redirect_to" value="<?php echo get_option('home'); ?>/wp-admin/" />

		<input type="hidden" name="testcookie" value="1" />
	</p>
</form>

<p id="nav">
<a href="<?php echo get_option('home'); ?>/wp-login.php?action=lostpassword" title="Password Lost and Found">Lost your password?</a>
</p>

Sidebar & Footer tags and closing Divs

I need to close the two divs I opened before, then I add in the tags for my sidebar and footer to appear :

</div>
</div>

<?php get_sidebar(); ?>
<?php get_footer(); ?>

The Complete Code :

<?php
/*
Template Name: Login Page
*/
?>

<?php get_header(); ?>

<div id="left">
<div id="archive">

<h2><?php the_title(); ?></h2>

<form name="loginform" id="loginform" action="<?php echo get_option('home'); ?>/wp-login.php" method="post">
	<p>
		<label>Username<br />
		<input type="text" name="log" id="user_login" class="input" value="" size="20" tabindex="10" /></label>
	</p>
	<p>

		<label>Password<br />
		<input type="password" name="pwd" id="user_pass" class="input" value="" size="20" tabindex="20" /></label>
	</p>
	<p class="forgetmenot"><label><input name="rememberme" type="checkbox" id="rememberme" value="forever" tabindex="90" /> Remember Me</label></p>
	<p class="submit">
		<input type="submit" name="wp-submit" id="wp-submit" class="button-primary" value="Log In" tabindex="100" />
		<input type="hidden" name="redirect_to" value="<?php echo get_option('home'); ?>/wp-admin/" />

		<input type="hidden" name="testcookie" value="1" />
	</p>
</form>

<p id="nav">
<a href="<?php echo get_option('home'); ?>/wp-login.php?action=lostpassword" title="Password Lost and Found">Lost your password?</a>
</p>

</div>
</div>

<?php get_sidebar(); ?>
<?php get_footer(); ?>

Creating the Page

Now you have the complete code, upload it to your theme directory and in your WordPress admin go to “Pages” > “Add New”. Name the page what you like and from thepage attributes on the right, choose “Login Page” from the Template dropdown :

Publish the page and your login page is now live. Logout and visit the page from your site and try logging in via it to make sure it works ok.


Post Tags

Author:

Oliver Dale is the founder of Kooc Media, a small internet company based in the UK. Kooc Media runs several high-profile websites including WPLift, ThemeFurnace and DesignersTalk.

Leave Yours +

64 Comments

  1. Brian Krogsgard

    Hey Oli,

    Is there is a reason you prefer this method over the native wp_login_form() function?

    http://codex.wordpress.org/Function_Reference/wp_login_form

    You could use that within your page template and save some trouble, unless I’m missing a benefit of doing it manually.

    • Hi Brian, yeah dropping in that function would replace the main chunk of code I listed,
      I have just always put the html by hand for greater customisation of the form.

      • Brian Krogsgard

        Ah, yeah. True enough. I’ll need to keep this in mind if I ever need to customize login. Good point : )

  2. Ozh

    Next: add rewrite from the regular wp-login.php page to your new login page.

    • Steve Ryan

      Ozh… Wondering if the Plugin Dev book book tells you how to do that exactly? Or is the rewrite accomplished server-side?

  3. What happens to the /wp-login.php link? Do you keep it up there, htaccess 301 it to your new login page or do something else?

  4. Abdelhadi Touil

    Thanks very much for this very helpful tutorial. Please, can you write a tutorial about custom lost password page? I didn’t find any such tutorial.
    Thanks again.

  5. Anonymous

    Nice post there! can you also tell me how to make a signup page like the one on this site please Thankx!!

  6. DM

    Now this is useful! Now all I need is a tutorial on creating a registration form… any ideas?

  7. Chris

    Nice simple solution, loads of blogs out there modifying CSS which is pretty pointless.

    Thumbs up!

  8. Unihost

    Absolutely awesome, so basic, still effective. Thanks for the code man.

  9. kamaradski

    Is there a way i can code my own credentials validation too ? instead of utilizing the original login.php ?

  10. Emperor1103

    How can I redirect the /wp-login.php to a page created through your template which requires the user to be logged in to access doens’t it?

  11. Lv111

    hi, great tutorial, but looks a bit unfinished. all login/logout links still lead to the native WP login page, login link in adminbar could lead to our new page…
    Am I correct that none of the plugins that needs wp-login will work with our new page?

    thanks!

  12. Wolfeb123

    how would I create a custom register or sign up page based on this?

  13. How about just using an ajax load statement to pull the login form into the current page?

  14. Jessica Paoli

    Thanks for this. 

  15. I very much please with this. it works fine with my theme. but how can one use this as the default wordpress login.

  16. Thank you very much Oliver, working like a charm and fully customizable.

  17. Thank so much, I looking this post long time ago… Thank!!! many many thank

  18. Help me! If user wrong password… How can i fix?

  19. Con I use it for Genesis Theme ? Or how to create same thing for genesis child themes..??

  20. Pls can anyone tell me where to open the old template to use to create the new one

  21. This looks great, could you tell me if you have done a tutorial on how to do the code for new customers and the database/table information.

    I need to create a new customer php page first then I can create a log in. Any help would be appreciated

    Thank you

  22. It is giving my fail login attempt error, even though my password and user name is correct.

    • Sorry, I had a function left orphan from older attempts of creating login page, in my funtion.php. Thats was creating error. After removing Its working fine now. Thanks

  23. Thank you for the auspicious writeup. It in fact was
    a amusement account it. Look advanced to far added
    agreeable from you! However, how can we communicate?

  24. When you have reached a peak in your life and you decide to sell, you will feel
    like going back in time and doesnt create any unnecessary problem.
    pittsburgh property management can possess offices within
    the structure they oversee or delegate and monitor from a separate
    facility. It is important to report what happened to the Better Business Bureau business and a part
    of NARPM, Greater Las Vegas Board ofRealtors.

  25. Hello to every one, because I am genuinely eager of reading
    this weblog’s post to be updated daily. It contains nice stuff.

  26. There are ways to create a Custom Login page for WordPress that are easier to implement. This is one of them:

    http://www.lockedowndesign.com/blog/create-custom-wordpress-login-page/

  27. We’re a bunch of volunteers and starting a brand new scheme in our community.
    Your site offered us with useful information
    to work on. You have performed a formidable task and our entire community
    will probably be thankful to you.

  28. I was very pleased to uncover this great site. I wanted to thank you for your time for this
    particularly wonderful read!! I definitely loved every bit of it and i also have you saved as
    a favorite to look at new information in your website.

  29. Thanks for some other informative blog. The place else may I get thaqt type of
    info written in such an ideal approach? I have a mission
    that I am just now running on, and I have been on tthe glance out for suchh info.

  30. I am not positive where you’re getting your info, but great topic.
    I must spend some time studying more or figuring out more.
    Thanks for fantastic info I was on the lookout for this info for my mission.

  31. Well, the idea behind this is that the mid is capable of some truly
    awesome things, and this really is a fact the medical and scientific industry
    continues to be harping a lot of the time. You can do these
    by sending signals which are similar to the language used by
    the brain brainwaves. To change peoples minds about smoking,
    the messages may go like these:.

  32. Điều này là thực sự thú vị, Bạn một blogger rất có tay nghề.
    tôi đã tham gia và mong muốn tìm kiếm thêm bài viết
    hay của bạn. Ngoài ra, tôi đã chia sẻ website của bạn trong mạng xã hội của tôi!

  33. When some one searches for his vital thing, thus he/she needs to
    be available that in detail, therefore that thing
    is maintained over here.

  34. Useful post.

    Thank u so much.

    Nguyen

  35. I’m gone to say to my little brother, that he should also pay a quick visit this webpage on regular basis
    to take updated from most up-to-date news.

  36. Its not my first time to pay a quick visit this web site, i am visiting this web page dailly
    and take good information from here daily.

  37. Hi, could this be used to then log into a different CMS system hosted on the same server?

  38. Video codecs are regularly-changing ‘filters’ that ensure videos
    you download to your PC can be played back through your
    favorite media player app. Go to Start ‘ Run and type Regedit.
    The video streaming capabilities of the Xbox 360 are one of the gaming system’s best features, and in fact my roommates and I decided to cancel cable
    once we’d realized how much more convenient streaming to
    our Xbox could be.

  39. Hi, I am just wondering and wanted to ask this question. I am trying your code locally before I try it on live site but the problem is that if the password is incorrect it goes back to wp-login.php.

    Any ideas?

  40. Hi

    How do I make the form not display if you are logged in?

  41. Whether you’re a teenage trying to earn some
    extra allowance for your next trip, or a single mother
    looking for easy ways to make ends meet, the internet can provide you with a wide range of opportunities to make money.
    You may be asking yourself how this is possible with just a blog.

    You can start with things you have around the house and then work your way up to getting some items wholesale once you
    can afford to make a few purchases.

  42. I’ve been surfing online more than three hours today, yet I never found any interesting article like yours.
    It is pretty worth enough for me. In my view, if all webmasters
    and bloggers made good content as you did, the web will be much more
    useful than ever before.

  43. Please let mme know if you’re looking for a writer for your blog.

    You havee some really good articles and I think I
    would be a good asset. If you ever want to take some
    of the load off, I’d love to write some articles for your
    blog in exchange foor a link back to mine. Please shoot
    me an e-mail iff interested. Thanks!

  44. Howdy! Someone in my Facebook group shared this website
    with us so I came to take a look. I’m definitely enjoying the information.
    I’m book-marking and will be tweeting this to my followers!
    Great blog and outstanding style and design.

  45. I all the time used to study piece of writing in
    news papers but now as I am a user of net thus from
    now I am using net for posts, thanks to web.

  46. When one has sufficient knowledge of what their body needs, then the search for the most fitting products may not be an arduous enterprise
    after all. As an alternative, they can decide on
    a serum that uses amino peptides that actually unwind cosmetic muscle contractions, bind
    drinking water towards the pores and skin, along with
    promote bovine collagen activity. Many people evaluate which varieties plus tones work very best to deal with as a result of an alternative connected
    with learning from your errors.

  47. I feel this is one of the such a lot vital information for me.
    And i’m glad reading your article. However should observation on some general issues, The site taste
    is great, the articles is in point of fact nice : D. Just right task,
    cheers

  48. Yeѕ! Finallү something ɑbout educational baby toys.

  49. I believe this is one of the so much important information for me.

    And i’m happy reading your article. But want to remark on few basic things, The
    web site taste is ideal, the articles is in reality excellent : D.
    Just right process, cheers

  50. Thank you for the good writeup. It in fact was a amusement account it.
    Look advanced to more added agreeable from you! By the way, how can
    we communicate?

Leave a Reply

* Required Fields.
Your email will not be published.

Search

Our Sponsors