Hide content from visitors until they log in

Posted on

By Michael Fields

There are a few reasons that you might want to hide content from users unless they are logged in to your site. If you find that this is your goal, the following example illustrates a very simple method to accomplish this.

<?php
if( current_user_can( 'read' ) ) {
    print '<h2>I AM LOGGED IN</h2>';
}
?>; 

Share your thoughts

*

Fork me on GitHub