Restricting pages

Hello, I am trying to restrict access and only allow users of a certain membership (in this case the user id is 1) to view a page.

i have duplicated page.php and renamed it page-63.php (which is the id of the page i want restricting) and the following code is in page-63.php

however, the page remains open to all, and i cannot for the life of me figure out what to do next, and i appreciate all pointers and help you may be able to give me.

[php]


<?php dynamic_sidebar( 'Page Sidebar' ); ?>
	<?php } ?>

	<div id="content-container" class="<?php if(get_field('inner_page_layout') == 'Sidebar Left') { echo 'two_third last'; } else if(get_field('inner_page_layout') == 'Sidebar Right') { echo 'two_third'; } ?>">

		<?php if ( have_posts() ) : ?>

			<?php while ( have_posts() ) : the_post(); ?>

				<article <?php post_class();?>>

					<?php while ( <?php if(is_user_logged_in() && tdp_hasMembershipLevel(1); ?>
<?php get_template_part( 'content', 'page' ); ?> <?php else; ?>

this is displayed to logged out users or logged in users with any membership other than 1

<?php endif; ?>
				</article>

			<?php endwhile; ?>

		<?php else; ?>

			<?php get_template_part( 'no-results', 'index' ); ?>

		<?php endif; ?>

	</div>[/php]

i have wrapped “<?php get_template_part( 'content', 'page' ); ?>” and im sure i have to do something with the while function, but i cant figure out where im going wrong

Is this a WordPress site?

Yep!

In the backend you can specify the group’s that can view a page. You would just need to change that portion.

I am unable to find that bit, have been told that I need to edit that code to get it to happen!

Here is another option

https://wordpress.org/plugins/pagerestrict/

Sponsor our Newsletter | Privacy Policy | Terms of Service