Hide all elements and exhibits if the user is not logged in

I'm looking for a way to hide every item and collection if the user is not registered and logged in. I want users to be able to register without admin intervention (with GuestUser) but I also need to make them accept certain terms before accessing the content.

I've been looking around building a simple plugin to redirect to a certain Simple Page if a guest user isn't logged in, but I don't have much experience with php and it seems like what I want is something that could be accomplished with just a couple lines of code.

Any help would be greatly appreciated.

I can see a couple different approaches to this. I haven't tested these, but they seem likely.

You might be able to accomplish this with a hack to the GuestUser plugin, provided that none of the items or collections are marked as public.

You could go into the hookDefineAcl method in GuestUserPlugin.php and change it from

$acl = $args['acl'];
$acl->addRole(new Zend_Acl_Role('guest'), null);


$acl = $args['acl'];
$acl->addRole(new Zend_Acl_Role('guest'));
$acl->allow('guest', array('Items', 'Collections', 'Search'), 'showNotPublic');

That would, in effect, make Guest Users have the same access as users with the Researcher role, giving them access to Items, Collections, and Search for non-public content.

Which leads to the next options -- just manually make all new Guest Users into Researchers. If there's a lot of guest users, or if it doesn't work to manually make all those changes, a plugin that that changes new guest users to the researcher role would do the same job.

Those mostly don't address the issue of having them accept terms, though. That would have to be a separate plugin if you want it to be automated. Or, if it is human(e)ly manageable, sending an email to new guest users to make sure they accept the terms, then changing them to researchers as described above, would work around that issue.

This is really helpful! Thanks

I'm having an issue though. After changing GuestUser.php I'm getting a blank page. Even after deactivating the plugin, downloading GuestUser again and installing it as a new plugin, it gives me a blank page. Is there something I'm doing wrong?


I was able to solve it, thank you. I'm wondering something though, would this break functionality of the Posters plugin?


Good question. Looking at the code, I suspect the approach of giving guest users the research role would break it, but if users still have the guest role, I don't see anything that would break. That's just from looking at the code, though. Only way to know for sure is to try it.

Seems like it doesn't. I have one last question. Now that the main page is mostly empty if the user is not logged in, is there anyway to redirect that page to a simple page, or to somehow prompt the user to register and login to view the content?

Thanks a lot!

Easiest thing along those lines is to go to Appearance -> Navigation, and select a home page from a Simple Page you create.

That won't, however, distinguish between a new visitor and a guest user who is already logged in.