Come together with the global Drupal community in Rotterdam, 28 Sept – 1 Oct 2026. Sessions, contribution, connection, and Early Bird savings until 8 June.
If you're referring to the login block on the left side of the screen, just browse to Administer > Site building > Blocks and change the settings. If that's not what you mean, you're going to have to be more specific...
The LoginToboggan module also gives you the ability to collapse that form or just make it a link...
Thanks for your simple solution/advice. I knew there would be a simple way to do this. For those of you who wonder why you would want to hide the login block, there are many reasons, but one of the most obvious is when you want to make a dynamic site look static--in other words, you would have no need for users to login to use the many interactive features of drupal. I think there is great opportunity here for people who want a simple website and also want to be able to edit it online without having to use web editing tools, uploading via ftp, etc. Again, thanks.
Administer->Site Building->Blocks - just turn off (set Region to ) the User Login block.
Be warned: if you do this then even if you have a different admin theme with the block appearing, then logins from the admin pages will still fail. I think it's because the submission of a login through Form API goes via the front-end theme, which doesn't instantiate the form on the page.
If you still want to log in using the admin block, then edit your frontend theme's block.tpl.php (stub it out from themes/engines/phptemplate/block.tpl.php if you don't already have it) and surround it with:
<?php
/* Redirect to a different page in the current directory that was requested */
$host = $_SERVER['HTTP_HOST'];
$uri = rtrim(dirname($_SERVER['PHP_SELF']), '/\\');
$extra = '?q=user/login';
header("Location: http://$host$uri/$extra");
exit;
?>
and set the login/logout menu items in my primary links, heavily weighted so that it shows up in the upper right corner of my pages.
Then I set the "User login" block that comes as the default to "Users cannot control whether or not they see this block" and set the page-specific visibility settings to php and included the following php code:
<?php
// Only show if $match is true
$match = false;
// See if the following matches
if (1 == 2) {
$match = true;
}
return $match;
?>
As long as 1 remains unequal to 2, the User login block will not appear on the site.
I also did not like the way I was always redirected to "My Account" after logging in. My site's content is what I want users to see first, not their personal info, so I set it up to always redirect to the home page by hacking the user.module file as follows:
I changed
Comments
If you're referring to the
If you're referring to the login block on the left side of the screen, just browse to Administer > Site building > Blocks and change the settings. If that's not what you mean, you're going to have to be more specific...
The LoginToboggan module also gives you the ability to collapse that form or just make it a link...
----------------------
Current Drupal project: http://www.ubercart.org
Built in settings to hide login...
Administer->Site Building->Blocks - just turn off (set Region to
<none>) the User Login block.That's how I did mine, then I just have a link to "/?q=user" without clean urls for a user to actually login.
I also use some php to use different features for anonymous vs. logged in users, mainly using
if($user->uid){do stuff;}or
if(!$user->uid){do stuff;}hiding the login block/making dynamic sites appear static
Thanks for your simple solution/advice. I knew there would be a simple way to do this. For those of you who wonder why you would want to hide the login block, there are many reasons, but one of the most obvious is when you want to make a dynamic site look static--in other words, you would have no need for users to login to use the many interactive features of drupal. I think there is great opportunity here for people who want a simple website and also want to be able to edit it online without having to use web editing tools, uploading via ftp, etc. Again, thanks.
Frontend and admin themes different (with different blocks)
Be warned: if you do this then even if you have a different admin theme with the block appearing, then logins from the admin pages will still fail. I think it's because the submission of a login through Form API goes via the front-end theme, which doesn't instantiate the form on the page.
If you still want to log in using the admin block, then edit your frontend theme's block.tpl.php (stub it out from themes/engines/phptemplate/block.tpl.php if you don't already have it) and surround it with:
if (! ($block->module == "user" && $block->delta == "0")):...
endif;Omit the very last ?> if you find yourself facing white screens of death.
--
J-P Stacey, software gardener, Magnetic Phield
You can create a login.php
You can create a login.php file like this:
Put it in the same folder of index.php
Then if you want to login, you can simply access http://www.example.com/login.php. Not really useful but quite nice ;-)
different login block
I disabled the standard login block,
disabled the 'logout' menu entry,
andd created a new block with teh following PHP code in it:
once you enable this block, you have a nice single link block that either says 'Login' or 'Logout', and redirects appropriately.
Thanks for posting this!
Thanks for posting this! It was very helpful to me.
Where do I create a new block?
Hi Cainan,
I tried to create a new block as your instruction using link admin/build/block/add and copied your code into Block Body. But it have not worked.
Could you please show me how I create aa new block?
Thanks
Nguyen Quoc Viet
How I did it
I installed the Login Menu module on my 5.x site
http://drupal.org/project/loginmenu
and set the login/logout menu items in my primary links, heavily weighted so that it shows up in the upper right corner of my pages.
Then I set the "User login" block that comes as the default to "Users cannot control whether or not they see this block" and set the page-specific visibility settings to php and included the following php code:
As long as 1 remains unequal to 2, the User login block will not appear on the site.
I also did not like the way I was always redirected to "My Account" after logging in. My site's content is what I want users to see first, not their personal info, so I set it up to always redirect to the home page by hacking the user.module file as follows:
I changed
to
(about line 962)
Seems to work
Thank you so much..it works for me!
Hello Webpotato,
Thanks a lot for sharing this info. It really worked for me.
All the best,
Tata