Show/hide content for logged in users in WordPress

I met this problem many time on freelance. You need to hide or show some content for logged in users. This is very simple but very useful part of code.
<?php if (is_user_logged_in()){ ?>
<h1>Content for logged in users</h1>
<?php } else { ?>
<h1>Please log in</h1>
<?php }; ?>
I just wanted to save this part of code not to forget this great is_user_logged_in() WordPress function. Have fun!

Leave a Reply

Your email address will not be published. Required fields are marked *