How To: Display Content To Registered Users Only

1st

Do you ever wanted to show content only to to registered users that are logged into your site? If yes, then here is a really fast the solution:

Just paste the following code on your functions.php file:
[php]
add_shortcode( ‘member’, ‘member_check_shortcode’ );

function member_check_shortcode( $atts, $content = null ) {
if ( is_user_logged_in() && !is_null( $content ) && !is_feed() )
return $content;
return ”;
}
[/php]

Then, all you must do is add some content in between your tags when writing a post or page like so:

[member]

This content is only for members.

[/member]

That’s all. If you enjoyed this article, please consider sharing it!

Leave a Reply

Sponsors