Hi guys, Thanks in advance for your help. I want to get some feedbacks on how I can accomplish this. I was able to show the "user login" fields to a specific page called "Login/Register". Now, what I want to happen is for this node/content/page "Login/Register" to be hidden once the user is logged in. What's the best way of doing this? Any ideas? I search the forum and I couldn't find anything that relates to Thanks.
Thanks in Advance!
Code is below to stick the block to "user login"

$nodeType = "user login";

// valid node id in view mode
if ( arg(0) == 'node' AND is_numeric(arg(1)) AND arg(2) == FALSE ) {

    $node = node_load(arg(1)); // cached

    if ( ($node->type == $nodeType) OR ($node->nid == 33) ) {
        return true;

return FALSE;


mjcarter’s picture

Not sure I understand the need to use the above code instead of the built in "User Login" block with visibility settings restricted to a single page.

This is not shown once the user is logged in by default.

Edit - I think I get it that you want the actual page it's hosted on to not be accessible.

You could use a rule to redirect people away from the page if they're logged in and hide the link to it with CSS.


.logged-in #menu-item {

amilayajr’s picture

Hi there,

Here's what I did and the reason I used the script I posted. What I did was only show the "user login" block in a specific node(content) named as "Login/Register". I get what you are trying to say. I can reposition this block in a different region but the theme(corporateclean) that I am using does not allow it well unless I add some codes which I am not good at all. What I want to happen is to hide the "Login/Register" node once the user signs in. If I don't restrict the "user login" block to just one "node/content" it shows up on every single content I have(i.e. sidebar) which annoys me(lol). Also it makes it look really nice if it's contained in a one node. Yes, you understood what I meant. Unfortunately I am no good writing codes and mostly relying on what people posted in the forums. I have to learn CSS, I was hoping this could be an easy coding.. it seems that is not....... by the way when say CSS, do I make a file with that extension and put it somewhere in my drupal installation with all the coding? Sorry I am total newbie. :(

stpaultim’s picture

Can't you use a module like 'content access' to simply restrict access to only admin or anonymous users?

Using this module, you should be able to set custom permissions for any node.

1) Create a LOGIN page with no content
2) Create a LOGING block that only shows up on LOGIN page
3) Use "Content Access" to only allow access the LOGIN page to admins and unauthenticated users.


I haven't tried it, but it is the route I would go.

amilayajr’s picture

Thanks for the info. That could work on a different aspect. However, what want to achieve is this. I restricted the "user login" block to only show in one content/node and I named it "Login/Register". Now what I want to happen is to hide this "Login/Register" content after the user logged in. I want this "user/login" block to show which contained in a content/node; it doesn't matter who the user is as long as they are not logged in. Once they logged in, I want it hidden. Hopefully what I am trying to say makes any sense. Thank you for your help.

stpaultim’s picture

Maybe I'm still confused.

To simply hide the block from logged in users you can use the permissions available for every block.
If you set the permission for User / Login to only display for "anonymous users' - then it would NOT display for ANYONE logged in.
In the settings for every block you can set visibility for "Pages," Content Types," "Roles," and "Users."

If, as I understand it, you are displaying the login information on a specific node, why not use "Content Access" or another module that allows you to set permissions at the NODE level. It is possible using contrib modules to set individual permissions on individual nodes. Simply hide the page/node you want to hide from any logged in user.

See this on Contact Access page - "Optionally you can enable per content access settings, so you can customize the access for each content node."

I neither of these options work, then I don't fully understand what you are trying to do.

amilayajr’s picture

Hi there. Thanks for the help. Yes I tried to use the Content Access module and enabled per node ACL. The problem I am really having is that since I put the "user login" block in a certain Content/Node; after the user login the message "access denied" shows up on that content. I was hoping maybe after they login they will be redirected to the "HOME" Content. Any ideas? Thanks.

amilayajr’s picture

Fixed the problem. I have used three modules, Content Access+ACL then I used "login destination" so that the user does not see the "Access denied" message after loggin in. Thanks guys. You guys rock!!