• Home
  • About
  • Job Profile
  • Portfolio
  • Training
Blue Orange Green Pink Purple

Show user login form in sidebar/template in wordpress

Posted in Web Development, Wordpress. on Tuesday, April 23rd, 2013 by lazyboy Tags: wp, wp login
Apr 23

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!

Saif The Green

  • View Saif's profile on LinkedIn
  • Recent Posts
    • RESTful API – The HTTPish …
    • SUSE – another user-friendly desktop Linux distributions
    • SEO meta techniques for a wordpress blog
    • Set favicon in cross browser and more…
    • WordPress custom URL rewrites and tips
  • Archives
    • October 2016
    • August 2016
    • August 2014
    • July 2014
    • April 2014
    • June 2013
    • April 2013
    • March 2013
  • Categories
    • CodeIgniter
    • Javascript
    • Linux
    • MySQL
    • opencart
    • php
    • SEO
    • Software Development
    • Web Development
    • Web Services
    • Wordpress
  • Meta
    • Log in
    • Entries RSS
    • Comments RSS
    • WordPress.org
  • Archives
    • October 2016
    • August 2016
    • August 2014
    • July 2014
    • April 2014
    • June 2013
    • April 2013
    • March 2013
  • Search







Saif The Green is proudly powered by WordPress
Entries (RSS) and Comments (RSS).