How to create a custom user login bar

Create a custom user login bar

In this how-to, I will show you how to create a user bar, that:

  • Displays a compact, nice user login form that can fit in one line.
  • Once user is logged in, It will display a welcome message and a couple of helpful links.

This is the final result we will be trying to achieve:

 the login form

 the welcome message after a successful login

As you can see, this how-to is written for Garland theme, the default theme for Drupal 5. But I'm pretty sure it can be easily used in any other theme.

Decide on the approach..

Drupal is very powerful, it's so flexible that you have many ways to do things. That's why a 5 minutes of thinking is very recommended before we get our hands dirty.

The solution I thought of will work like this:

  • We will write a separate function, will call it garland_user_bar(). It decide, and return HTML for the login form, or the welcome message. It will contain the necessary code to check which one it should return.
Syndicate content
 
 

Drupal is a registered trademark of Dries Buytaert.