In this tutorial, we'll show how to hide content from logged-in Joomla users.
Why would you want to hide information from logged in users? The most common reason to do this that you want to encourage visitors to join the site. Then, if a visitor logs in, they no longer need to see the "join now!" content.
Fortunately, this is really easy to do with the "Guest" feature in Joomla. This guide will show you how to hide content without using any extensions.
Step #1. Getting set up
First, let's check that our site is set up correctly.
- From the Administrator side, go to Users > Groups.
- If you're using older versions of Joomla, you'll need to add a new "Guest" group that has "Public" as its parent. In Joomla 3, just verify that it's already there.
- Go to Users > Access Levels.
- In Joomla 2.5, you needed add a corresponding access level called "Guest". In Joomla 3, just verify that it's already there.
- From the Users screen, click on the "Options" icon.
- Look for the "Guest User Group" field and make sure it is set to "Guest".
Step #2. Add an article for guests
Let's create two articles that we can use for our testing:
- Go to Content > Article Manager > Add New Article.
- Add the title and content you want the non-logged-in users to see.
- Set the "Access" option to "Guest".
- Set "Featured" to "Yes", because we want this article on the home page.
- Click "Save & New".
And now let's repeat this and create an article for our registered users.
- Enter the title and body of article to be seen by your logged-in users.
- Set the "Access" option to "Registered" and the "Featured" option to "Yes".
- Then click "Save & Close" from the toolbar.
Finally, we'll create a new user to use for testing:
- From Users->User Manager->Add New User
- enter the login information of a new user: Name, Login Name, Password (twice) and email address.
- Click on the Assigned User Groups and verify that it defaults to Registered.
- Click Save & Close.
Step #3. Test Your Site
Now let's make sure everything is working correctly:
- Browse to the public side of the site.
- Notice that the home page has the article that was set to Public access.
Now we'll view the homepage while logged in.
- Enter the User name and password of the user you created into the Login Form.
- You'll now see the article on the home page that was set for Registered access, and NOT the article whose Access was Guest.
You can use this same process with menu items and modules for even more content hiding and showing. This technique is valuable for any site where you're encouraging people to join: Paid content sites, tutorial sites, dating sites, homeowner association sites, church membership sites. etc.