free tuts

Sometimes we need to show content only to logged in users. For this purpose we ask the users to register and upon log in they may view hidden from unregistered users content. To achieve this is fairly simple: we again use conditional tag. We may hide the content on any page (or all pages) of the website using/or repeating same piece of code.
Here, we go:

On the screenshot above we see a page where content is hidden with request to login or register. In the code above first part is a regular loop with content template part. Second part of the code shows a form with username and login. Once user logs in he/she is redirected to the same page but content now is unrevealed. And here is how the page looks after logging in: