Hello,

I am looking for a way in Drupal 7 that will require users to log in to a site before they have access to it. I found some modules like "Require Login" for Drupal 6, but no modules for Drupal 7 that will do this task simply. Is there a module out there I missed? If not, is there a way I can configure Drupal natively or with other modules to complete this task?

The site I am working on is intended to be a private group site, where nobody can access anything on the site without first logging in. I already disabled public registration.

Thanks in advance.

Comments

WorldFallz’s picture

This is part of core behavior-- simply remove the 'view published content' permission for the anonymous role.

warriors2832org’s picture

I already went through and disabled all of the anonymous user permissions except for the permissions required for certain modules to function (View published content is disabled). Even though anonymous users can't access the site, the site still looks "welcoming" with sidebar and other links still available. Is there a way I can make it look less welcoming, like turning off all blocks and making the login screen the home page?

Thanks.

nevets’s picture

You can set block visibility by role, so for the blocks you do not want them to see you could set it so only authenticated users can see them.

jimbean’s picture

I believe this approach will work, but it may not be the best practice.

So below is an example of where I want a log in link to appear when the end user is not logged in and a log out link to appear when the end user is logged in. Just remove the two lines and replace it with what you need to show or not show. I added this code in the page.tpl.php file.

    global $user;
    if($user->uid != 0){
        echo "<a href=\"/?q=user/logout\">Client Logout</a>"; //remove this line
    }
    else{
        echo "<a href=\"/?q=user/login\">Client Login</a>"; //remove this line
    }