Many of you wanted to use the WordPress login in your wordpress plugin or theme. WordPress made it really easy so that user can login to wordpress by using your wordpress plugin or theme. How to do it? Just be with me till the end of this post ;)
Few things you should know:-
get_site_url() :- Get the home url of current wordpress blog.
get_permalink() :- Get the current page url you are in.

Here is the code through which you can do it:-

1
2
3
4
5
6
7
8
9
<form method="post" action="<?php echo get_site_url(); ?>/wp-login.php" name="loginform">
	<p><label>username</label></p>
	<input id="user_login" name="log" type="text">
	<p><label>password</label></p>
	<input id="user_pass" name="pwd" type="password">
	<input id="button" name="button" value="Login" type="submit">
	<input type="hidden" value="login" name="action">	
	<input type="hidden" value="<?php echo get_permalink(); ?>" name="redirect_to">			
</form>

How this form works

As you can see we are submitting the values of the form to wp-login.php page which verify the userid and password entered by the user. Also you can see a hidden field called as ‘redirect_to’ which returns the user to page on a successful wordpress login.
If you want to redirect user to another page on a successful login than you define this “redirect_to” hidden field with another url.