Sometimes the login block that is created from a Drupal theme isn’t as pretty as we might like. The ability to create custom login block really can be useful. Of course, you can take the time to edit the template files, but that can be complicated.
In this tutorial, we have two different components for a custom login block. The first is the block for logging in and the second is the block for when you are logged in. For both of these options, you’ll need to have the ability to use the PHP input type. If your user role doesn’t have the ability, you won’t be able to use this tutorial.
Here are the instructions.
Custom Login Block
- Go to your blocks page (http://www.example.com/admin/build/block) and create a new block.
- You can give it any title you want. The most important part is to take the contents of this file (right click and save as for best results) and put it in the block body and select PHP Code as the Input format.

- You can edit this code anyway you want. Since I am not a pro with HTML I use Dreamweaver to edit the code. You’ll notice that I have it in tables for easy formatting, but if you understand <div> elements better than I do, you can really go to town on the formatting of the form.
- I make sure that this block is only visible for anonymous users so I make sure that that is selected:

- After you save the block, you can put it in your side bar or other block location.
- Here is an example of what this will look like in your sidebar

Custom Logged In As Block
- To Create a Custom Logged In as block that allows the user to have easy access to their account and a log out button, you’ll need to create a new block (http://www.example.com/admin/build/block) with this code (right click and save as for best results).

- In this case, I only want this to appear for people that are authenticated:

- When you save this block, put it in the sidebar location of your choice.
- Here is an example of what it will look like:

Some Notes
- You can create these in one block if you like but you’ll need to use PHP to control the visibility. I don’t do that here because I like the login block and the logged in as block to be in different locations.
- Because this code is PHP, you are not limited to putting it in a block. You can put it directly in your theme template or on a different page.
- This code is designed to leave people on the same page they were before they logged in. Sometimes this has some unintended results… it will redirect the user to a page not found error. If this becomes a problem you can change this destination to another page, like the user page.



