Register an account
E-mail will only be used to recover your login information
Easy user registration and login/logout in Wordpress

Easy user registration and login/logout in WordPress without plugins

Let users register and login from your front page

Only a few days after launching my new blog design, I’ve already received a couple of e-mails from other WordPress users asking me how I implemented the registration and login function of my blog from the front page, and the answer couldn’t be any simpler. Using a few simple preset PHP functions and a couple of specific name values, we can let users register, login and log out from anywhere we want.


Both functions rely on a set of specific form and input names, sent to a specific parser. For example, since my domain is, my login and registration requests are parsed on


You can try it out right here! Just scroll up and check out the top-left portion of your screen. Click the question mark icon to register, or if you’ve already done so, simply login right at the top of the page.


WordPress has a built-in function to return your site’s login and logout URLs. They are:


Using those functions, we can easily create a customized login form and by checking if the user is already logged in, we can present the logout button. Let’s take a look at an example form, and then decipher it.

<?php if ( is_user_logged_in() ) { ?>
	<a href="<?php echo wp_logout_url(get_permalink()) ?>">Logout</a>

<?php } else { ?>
	<form id="login" method="post" action="<?php echo wp_login_url( get_permalink() ) ?>">
			<input type="text" value="" name="log" /></label>
			<input type="password" value="" name="pwd"  /></label>
			<input type="submit" />

The first thing we do is check if the user is logged in by running if ( is_user_logged_in() ). If the user is logged in, then we present the logout button. If he’s not logged in, then we present the login form. I’ve added the get_permalink() function to the parameters, which will redirect users to the current page once they hit submit and their credentials are checked.

The form itself is quite simple. The parser checks for specific name values, so it’s important to keep the form and label names. That’s all their is to the login form, and logout button.


Registration, much like the login and logout form, is quite simple and relies on a few key elements.

<form name="registerform" action="" method="post"> 
		<input type="text" name="user_login" value="" /></label> 
		<input type="text" name="user_email" value="" /></label> 
		<input type="hidden" name="redirect_to" value="" /> 
		<input type="submit" name="wp-submit" />

The form’s action points to your blog’s login URL, with the action=register parameter. The rest of the form functions like the login and checks for name sets.

That’s all there is to it. Implement to your sidebar, header or in your content, style accordingly and enjoy.


I’ve noticed that WordPress 3.0 also implemented a function that does this. I’m still looking into the best way to use this.

<?php wp_login_form( $args ); ?>

Notice: this article was written for WordPress 3.0

While it is unlikely that near-future revisions of WordPress will break these functions, it still remains a possibility. If you are running a busy blog, you may want to keep this in mind before implementing the feature, or at least keep a close eye on it after updates.

How-to Wordpress

Something on your mind?

Leave a comment and let the world know.


Woah, you're not logged in! Would you like to login or register?

Your Ad Here
  1. NewMediaSolutions
    July 29, 2010 at 3:06 PM

    Excellent information! We searched Google for a long time before we were able to find your website with the registration information. We just couldn’t find it anywhere else! Thanks again!

  2. Roy
    October 21, 2010 at 2:27 PM

    I’ve seen several of this implementation but if you enter something wrong or you leave it blank and click on submit, it will still direct you to the WP standard login page. Now the question is how to get around that by somehow retrieving the error messages and display it on the same page as the login/register.

  3. Sagive
    November 24, 2010 at 2:35 PM

    Yee!! thanks man.. been looking for such a clear explenation..

    i want to use such a “register” box that has 2 feilds to
    register new users to me website “EMAIL LIST”…

    the wrong approach?

  4. Natural Vitamins
    December 3, 2010 at 12:51 PM

    when it comes to video games, i enjoy playing those that have very nice graphics and story like Plantz and Zombies *::

  5. gala
    January 19, 2011 at 1:23 AM

    I hope this works with 3.0.4 v of wordpress. Do you have any suggestion if your templates doesn’t support register-login? Thanks a lot with this article. Great Job!

  6. Joe
    May 24, 2011 at 2:25 AM

    How about the expandable form action? I really would like to do that with the form.


  7. Kristiyan Lukanov
    July 21, 2011 at 6:16 AM

    I’m searching for a custom wordpress registration page, and this setup here is so simple and customizable.
    Thanks for the info.

  8. amit
    July 22, 2011 at 7:59 AM

    i don’t know why, but the basic steps like where exactly put the code above is not mentioned any where. i am totaly lost in which files of wordpress should all this customiation put?

  9. Harold
    September 11, 2011 at 12:58 PM

    Can you tell me where this code would go?
    I don’t know which page to put this on, but it looks amazing!

  10. vanessa
    November 11, 2011 at 10:54 AM

    how do we go about into adding extra fields in the register form? Like phone number ? I’m sure we’ll probably have to edit the tables in wordpress.

  11. lanzon
    January 19, 2012 at 9:26 PM

    hi guys im simple person bt malibog hehehehe tra usap tau

  12. dasdadd
    February 8, 2012 at 3:17 AM


  13. Hitish
    July 5, 2012 at 4:12 AM

    Nice integration of functions and clear explanation

  14. salman
    August 16, 2012 at 6:11 AM

    thnx! this is awesome information for me.

  15. rene
    September 1, 2012 at 11:54 AM

    this is a coment

  16. lorgio
    September 1, 2012 at 11:56 AM

    this a comment test

  17. Rubén
    September 18, 2012 at 8:09 PM

    Thanks a lot for this information!

  18. bloodstriker
    December 8, 2012 at 8:50 AM

    hello – i just wanted to ask u – if there is a plugin that does this?
    i am just new to php or wordpress at all , and i dont know how to write code, but i want to have this login/logout and register form into my blog(that is not finished yet).
    i got some plugins that says “register form”, but they only put the reg form there, and the login/logout buttons are not available :(.
    so may be to explane this in more words – for like an idiots like me , or just tell some plugin that have all options, and it is not that hard to configure ….
    thanks you in advance – i relly do need the help – it is for homework, and if i dont do it i could get an F, so i’ll fail :(((.
    really appriciate it.

    best wishes


  19. Frank Martin
    April 29, 2013 at 1:48 PM

    Tutorial is not bad. but it would have been a click bank if you had covered this way.
    1) how to make a front end registration,login system with out going to wp-admin and not showing wp-admin in url
    2) profile picture upload and display on front end, including show/edit profile of user. it can cover alot more to make it a compact tutorial which could have become a must go place for visitors.

  20. acne killer
    June 11, 2013 at 11:12 AM

    Blackheads look like small brown or black dots on your skin, acne killer prone skin.

    March 12, 2014 at 10:11 PM

    Hmm it looks like your website ate my first comment (it was extremely long)
    so I guess I’ll just sum it up what I submitted and say, I’m thoroughly enjoying your blog.
    I as well am an aspiring blog blogger but I’m still new to everything.

    Do you have any points for novice blog writers? I’d really appreciate it.

Get a Dropbox!