WordPress tutorials: Member only content

Wpsnipp – If a visitor is not logged in, they will be redirected either to the WordPress login page or a page of your choice. Once logged in they can be redirected back to the page that they originally requested. Adding this PHP code to the functions.php file of your wordpress theme will allow you to place content you only wish members to see within the members short code [member][/member].



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 '';


This text will be only displayed to registered users.

Leave a comment