Forums

restrict pages to authenticated users. (6 posts)

  1. periferral
    Member
    Posted 4 years ago #

    Hi. I want to have pages with https redirection and then authentication if possible. I was wondering if there was a way in wordpress to do this. I searched the forums but wasnt able to come up with much.

    I dont want to use the pages authentication if possible. Id rather that a page only be visible to registered users.

  2. Otto
    Tech Ninja
    Posted 4 years ago #

    Making a page template that will only display the page content to registered users is fairly easy. Just copy the theme's index.php to a Page Template (and add the Page Template header), then use this bit of code:

    if (is_user_logged_in()) {
    // code to display the page goes here
    } else {
    // code to say "you must be logged in to see this page" goes here
    }
  3. harknell
    Member
    Posted 4 years ago #

    As an easier method you could also utilize my AWSOM News plugin, which has options to display content within a news post to only certain levels of registered users, or to only non-registered users. The News post can be added to any post, page, or set to display on your index page, or any theme location using a code. Each News post is individually set for user level that can view the content.

  4. educationthemes
    Member
    Posted 3 years ago #

    Otto that sound great but how would i use the code above in this template below:

    <?php
    /*
    Template Name: Protected Page
    */
    ?>
    
    <?php get_header(); ?>
    
    	<div id="content">
    
    		<?php if (have_posts()) : ?>
    
    		<?php while (have_posts()) : the_post(); ?>
    
    		<h2><?php the_title(); ?></h2>
    
    		<?php the_content(); ?>
    
    		<?php endwhile; else: ?>
    
    		<p><?php _e('Sorry, no posts matched your criteria.'); ?></p>
    
    		<?php endif; ?>
    
    	</div>
    
    	<?php get_sidebar(); ?>
    
    	<?php get_footer(); ?>
    
    </div>

    Thanks

  5. flick
    Member
    Posted 3 years ago #

    You might find this post helpful. Credit to Dr C.

  6. monkeymiles
    Member
    Posted 3 years ago #

    I use these two plugins to control access. Some feedback on actually how effective they are would be appreciated. Have a look at my missus site koester.co.uk. You shouldn't see any posts.

    WP-Sentry
    http://www.peteholiday.com/wp-sentry/

    I think this first one does what you want

    Private Plus
    http://wordpress.org/extend/plugins/privateplus/

    This second one allows you to lower the level at which the private stuff can be seen

Topic Closed

This topic has been closed to new replies.

About this Topic