Jul 6th by Neil under Hints and Tips, Tutorials, Wordpress
As you can see I use a sidebar login for here on Effutio.com that completely bypasses the standard WordPress 2.8 login screen page. No big deal you may be thinking but it is one less page that users have to wait to load, it adds a professional look and encourages people to login.
OK now that you are convinced that being able to login from home page (or any page where the code is placed) I’ll show you how to achieve it. Ive placed my login form at the top of the sidebar but feel free to experiment putting it elsewhere (maybe the header).
So we need to create a form that captures and the users login details, here is mine:
Insert this form code into your sidebar code probably between some <li> tags and hey presto you have a login form that allows users to login directly from the page. You will also see a checkbox allowing users to stay logged in too just like the standard WordPress login page (so we dont lose any functionality).
Lets expand on the above form by adding the option for users to register and recover their password if forgotten! These two lines of code do the job:
Excellent now it looks really professional and has everything we need…….or does it. What about logging out I hear you cry! Yeh it would be cool if the option to logout only appeared if the user was already logged in! Well I’ll show you how to do that too. So how do we say ‘if the user is not logged in show the the login form and if not show the alternative menu with logout option’? Like this:
Login
Control Panel
You can see that I display a control panel menu when the login form is not displayed. This code is taken directly from my sidebar.php file and of course you will probably have to adapt it slightly to fit your own theme.
This code is designed to work with WordPress 2.8+, it wont work in previous versions.
You can take this hidden menu further and I do in my next tutorial here
Related Posts:
- Menu only logged in users or certain users can see
- Display your WordPress posts on other pages
- More Advanced Menu only logged in users or certain users can see
- Using Google Adsense for Search in WordPress
- Page Templates in WordPress
- Using multiple/different headers, sidebars, footers and comment templates in WordPress


Two wrong with this:
1, What should be logged in to see the non-logged in to see
2, is not good for the logout link
Erm… two things wrong with your comment
1. Non-logged in users see a login screen:
< ?php if ( ! is_user_logged_in() ){ ?> translated: If user is NOT logged in display following!!
2. This is good for logout if you use WordPress 2.7+, I can only think you run an older version of WP
Hi Neil,
Thanks for this code, did the job for me. Wanted to point out in the very first snippet…
line 1: ('home') should be (‘home’)
line 12: ['REQUEST_URI'] should be ['REQUEST_URI']
Was probably just some unwanted formatting from when you posted the article. It took me a few minutes to figure out why my page was breaking up, as my sidebar wasn’t wide enough to display the syntax error LOL.
Thanks Again!
Thanks Chris, it was a plugin I had installed and since taken off that cause the weird syntax issue. Thought Id got them all but obviously not. Thanks again.