Skip to content

Instantly share code, notes, and snippets.

@pingram3541
Last active January 28, 2018 10:22
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pingram3541/6c862d72ea6f8d4f6576073d60c971ba to your computer and use it in GitHub Desktop.
Save pingram3541/6c862d72ea6f8d4f6576073d60c971ba to your computer and use it in GitHub Desktop.
How to restrict betheme content for paid membership pro - copy to child theme
<?php
/**
* The template for displaying all pages.
*
* @package Betheme
* @author Muffin group
* @link http://muffingroup.com
*/
get_header();
?>
<!-- #Content -->
<div id="Content">
<div class="content_wrapper clearfix">
<!-- .sections_group -->
<div class="sections_group">
<div class="entry-content" itemprop="mainContentOfPage">
<?php
while ( have_posts() ){
the_post(); // Post Loop
/* custom code to filter paid membership pro */
$hasaccess = pmpro_has_membership_access(NULL, NULL, true);
if(is_array($hasaccess)){
//returned an array to give us the membership level values
//$post_membership_levels_ids = $hasaccess[1]; //gives us all level ids
//$post_membership_levels_names = $hasaccess[2]; //gives us the level names
$hasaccess = $hasaccess[0];
}
if($hasaccess){
mfn_builder_print( get_the_ID() ); // Content Builder & WordPress Editor Content
} else {
?>
<div class="section_wrapper">
<div class="the_content_wrapper">
<p>Sorry, this page requires a Membership Account.</p>
</div>
</div>
<?php
}
}
?>
<div class="section section-page-footer">
<div class="section_wrapper clearfix">
<div class="column one page-pager">
<?php
// List of pages
wp_link_pages(array(
'before' => '<div class="pager-single">',
'after' => '</div>',
'link_before' => '<span>',
'link_after' => '</span>',
'next_or_number' => 'number'
));
?>
</div>
</div>
</div>
</div>
<?php if( mfn_opts_get('page-comments') ): ?>
<div class="section section-page-comments">
<div class="section_wrapper clearfix">
<div class="column one comments">
<?php comments_template( '', true ); ?>
</div>
</div>
</div>
<?php endif; ?>
</div>
<!-- .four-columns - sidebar -->
<?php get_sidebar(); ?>
</div>
</div>
<?php get_footer();
// Omit Closing PHP Tags
@tahir491
Copy link

tahir491 commented Oct 7, 2017

@pingram3541
Thanks a lot for your help. Really appreciate!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment