Support » How-To and Troubleshooting » How to make a blog member-only

How to make a blog member-only

Viewing 3 replies - 1 through 3 (of 3 total)
  • Don’t use plugins for things that is so easy to modify via page templates.

    Example template code:

    Template Name: Members only
    	<div id="maincontent">
    			<div class="page">
    <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
    			<div class="post" id="post-<?php the_ID(); ?>">
    			<h1 class="newstitle"><a href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?></a></h1>
    			<div class="postcontent mt20">
    			<?php if (is_user_logged_in()) : <strong>// CRUCIAL!</strong> ?>
    			<?php the_content(__('(Read more..)')); ?>
    			<?php else : ?>
    			<div class="errorbox">
    			<h2>Sorry.</h2><p>This page requires that you are a member of this page, please log in or become a member.</p>
    			<?php endif; ?>
    			</div><!-- postcontent end -->
    			</div><!-- post end -->
    			<?php endwhile; else: ?>
    			<p><?php _e('Sorry, no posts matched your query.'); ?></p>
    			<?php endif; ?>
    			<?php posts_nav_link(' — ', __('< Previous page'), __('Next page >')); ?>
    			</div><!-- page end -->
    	</div><!-- maincontent end -->

    Tommie Hansen
    Dekorfilm.se | Mindescape Reklam

    Thank you so much!

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘How to make a blog member-only’ is closed to new replies.
Skip to toolbar