Created
June 14, 2016 14:30
-
-
Save andrewlimaza/37b428791abf9fb33a4a79e922bd99d6 to your computer and use it in GitHub Desktop.
Paid Memberships Pro content restriction for Muffin Builder plugin
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| /** | |
| * The template for displaying all pages. | |
| * | |
| * Please create this as a custom page template in WordPress by simply adding this (page.php) to your active child theme's directory. | |
| * | |
| * @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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment