Show user login form in sidebar/template in wordpress 

Recently, i was looking for a solution to show a simple user login form in site sidebar, googled but it referred for using plugin like sidebar-login. Suddenly i got wordpress have already its native function to use for login form.

wp_login_form()  allows to add the form in any place you wish. some parameters exist there to control the form attributes. i can just put your attention to the following :

  • redirect‘ — where to redirect after login
  • remember‘ — whether to remember the values.

Let us see an example:

if (is_user_logged_in()) {
   echo 'Hello, ', $user_login, '. <a href="', wp_logout_url(), '" title="Logout">Logout</a>';
} else {
   wp_login_form();
}

here, we just checked for logged in user to show different message.
If you want you can customize the look of the form by defining extra css putting it within a div as following screen.
login
So instead of using a plugin with extra feature,using native function is as easy as better!