Forum

Thread tagged as: Question, Addons, Members

Restricted access for whole site using Members App

I'm wanting to develop a 'Brand Guidelines' site on a separate install of Perch. I want the whole site restricted to logged in members only, so once logged in they can download logos and view pages etc.

Can the Members App be used to restrict access to the whole site, so they have to login via the homepage to gain access to the site? If yes, any ideas How I would do this ?

Thanks Mark

Mark Watts

Mark Watts 0 points

  • 6 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

Yes, absolutely. At the top of your main layout, you could just do this:

if (!perch_member_logged_in()) {
     PerchSystem::redirect('/login');
}

Worked a treat thanks. I added the above to the global.header file and for the login page used login.header without the code so that it displayed the login or register form.

Once logged it redirects you to the homepage with all the site and content displaying :o)

        {
            echo '<p>You are not logged in. Please login or <a href="/register">register</a>.</p>';
            perch_members_login_form(); 
        }
        if (perch_member_logged_in()) {
             PerchSystem::redirect('/');
        }

Thanks