Theming Drupal user login page
Getting a page template for the user login page should be as easy as copying your page.tpl.php file and renaming it to page-user-login.tpl.php. Problem is when I tested this It didn't run on /user but only on /user/login. To get the same template file to run on both you add in your template.php:
function YOURTHEME_preprocess_page(&$vars) {
// Check to see that the user is not logged in and that we're on the correct page.
if ($vars['user']->uid == 0 && arg(0) == 'user' && (arg(1) == '' || arg(1) == 'login')) {
// Add a custom template-file.
array_unshift($vars['template_files'], 'page-login');
// Add body classes for easier css.
$vars['body_classes'] .= ' userlogin';
}
}
Note you could add arg(1) == 'register' or 'password' to have it set on those pages as well.
The last part adds a body class for our login page so that you in your theme can use for example:
.userlogin a {
color: green;
}
That CSS will only be visible on the /user and /user/login for anonymous users. The body class .page-user that you will have as a default is also set on /user for authenticated users.
Now copy your page.tpl.php and rename it to page-login.tpl.php. Then flush all caches an you should be good to go to edit your page-login.tpl.php file without affecting other pages.

Hej Det måste vara nått fel i
Hej
Det måste vara nått fel i syntaxen?..dreamweaver visar att det är något som är fel och så fungerar inte tampleten alls...
Aj då, en missad parentes :)
Aj då, en missad parentes :) Nu ska det fungera.
nice theme! Thx for
nice theme! Thx for sharing!!
welcome to visit my blog at www.x-ck.com
Hi, I tried doing this, but
Hi,
I tried doing this, but it doesn't seem my changes are taking effect. I double-checked my code and cleared up my theme registry. Any help?
Referring to my previous
Referring to my previous comment, I tried changing page.tpl.php and it worked fine. But when I copied page.tpl.php and renamed it to page-login.tpl.php, the changes went away. Any help?
Once again, referring to my
Once again, referring to my previous 2 posts, it seems page-user-login.tpl.php works great. However when I use the code above in YOURTHEME_preprocess_page and then try page-login.tpl.php, it seems to fail. Could it possibly be because I'm using a subtheme and hence array_unshift($vars['template_files'], 'page-login'); is referring to a file in the main theme?
Hi, have you switched
Hi, have you switched YOURTHEME for your own theme name? This works on a sub-theme as well. Also have you cleared all caches afterwards at /admin/settings/performance?
Thanks alot! I think there is
Thanks alot! I think there is a tiny typo in the code. If my template file is called page-user-login shoudn't the next line be like this (at least this one worked for me):
array_unshift($vars['template_files'], 'page-user-login');