Membership: Page Templates two different templates for two diff levels- one page.

Alright so fun question here...I am running membership pro. with a nice theme. I open the page template in dreamweaver and am using a <?php echo do_shortcode();?> in my header and it works great to show a bookshelf to only certain users of which I have many different levels. As you can see from my attached txt file I am trying to have two different page styles, one with three columns, and the other with only one but full width.

I am not proficient in any code but have added the shortcodes [level-bl][/level-bl] in the area where the first page layout differs from the second layout

any suggestions on how to make this work?

thanks!

  • Matt

    attachment might have an issue...

    <?php
    /**
    Template Name: APM Library
    *
    * @package Natural
    * @since Natural 3.0
    *
    */
    get_header(); ?>

    <div id="featurebanner" align="center"><?php echo do_shortcode('[level-bl][bookshelf id="801" btn_titles="Titles" btn_icons="Icons" item_width="100%" item_height="240" products_box_margin_left="30" product_title_textcolor="#ffffff" product_title_bgcolor="#c33b4e" product_margin="30" product_show_title="true" show_title_in_popup="true" show_selected_title="true" show_icons="true" thumbs_effects="true" buttons_margin="15" buttons_align="center" slide_duration="1000" slide_easing="easeOutQuart" arrow_duration="800" arrow_easing="easeOutQuart" video_width="500" video_height="290" iframe_width="500" iframe_height="330" exclude_products="" orderby="modified" order="DESC" categories="apm-library" post_type="bookshelf"][/level-bl]');?></div>

    <!-- BEGIN .post class -->
    <div <?php post_class(); ?> id="page-<?php the_ID(); ?>">

    <?php if ( has_post_thumbnail()) { ?>
    <div class="feature-img banner shadow radius-full"><?php the_post_thumbnail( 'featured-large' ); ?></div>
    <?php } ?>
    [level-bl]
    <!-- BEGIN .row -->
    <div class="row">

    <!-- BEGIN .four columns -->
    [level-bl]<div class="four columns">[/level-bl]

    <?php get_sidebar('left'); ?>

    <!-- END .four columns -->
    </div>

    <!-- BEGIN .eight columns -->
    <div class="eight columns">

    <!-- BEGIN .postarea middle -->
    <div class="postarea middle">

    <?php get_template_part( 'loop', 'page' ); ?>

    <!-- END .postarea middle -->
    </div>

    <!-- END .eight columns -->
    </div>

    <!-- BEGIN .four columns -->
    <div class="four columns">

    <?php get_sidebar(); ?>

    <!-- END .four columns -->
    </div>

    <!-- END .row -->
    </div>

    <!-- END .post class -->
    </div>[/level-bl]

    <!-- BEGIN .row -->
    <div class="row">

    <!-- BEGIN .sixteen columns -->
    <div class="sixteen columns">

    <!-- BEGIN .postarea full -->
    <div class="postarea full">

    <?php get_template_part( 'loop', 'page' ); ?>

    <!-- END .postarea full -->
    </div>

    <!-- END .sixteen columns -->
    </div>

    <!-- END .row -->
    </div>

    <?php get_footer(); ?>

  • Vaughan

    Hi Matt,

    Hope you're well?

    It looks like it's because you are using nested levels.

    In short you have it like this;

    [level-bl]
    
    Some code here...........
    
    [level-bl]<div class="four columns">[/level-bl]
    
    some  more code here ..............
    [/level-bl]

    also you haven't actually used the do_shortcode() in the code.

    I would probably use the PHP functions rather than shortcodes on this.

    <?php
    /**
    Template Name: APM Library
    *
    * @package Natural
    * @since Natural 3.0
    *
    */
    get_header(); ?>
    
    <div id="featurebanner" align="center"><?php echo do_shortcode('[level-bl][bookshelf id="801" btn_titles="Titles" btn_icons="Icons" item_width="100%" item_height="240" products_box_margin_left="30" product_title_textcolor="#ffffff" product_title_bgcolor="#c33b4e" product_margin="30" product_show_title="true" show_title_in_popup="true" show_selected_title="true" show_icons="true" thumbs_effects="true" buttons_margin="15" buttons_align="center" slide_duration="1000" slide_easing="easeOutQuart" arrow_duration="800" arrow_easing="easeOutQuart" video_width="500" video_height="290" iframe_width="500" iframe_height="330" exclude_products="" orderby="modified" order="DESC" categories="apm-library" post_type="bookshelf"][/level-bl]');?></div>
    
    <!-- BEGIN .post class -->
    <div <?php post_class(); ?> id="page-<?php the_ID(); ?>">
    
    <?php if ( has_post_thumbnail()) { ?>
    <div class="feature-img banner shadow radius-full"><?php the_post_thumbnail( 'featured-large' ); ?></div>
    <?php } ?>
    <?php if(current_user_on_level( $level_id )) { ?>
    <!-- BEGIN .row -->
    <div class="row">
    
    <!-- BEGIN .four columns -->
    <div class="four columns">
    
    <?php get_sidebar('left'); ?>
    
    <!-- END .four columns -->
    </div>
    
    <!-- BEGIN .eight columns -->
    <div class="eight columns">
    
    <!-- BEGIN .postarea middle -->
    <div class="postarea middle">
    
    <?php get_template_part( 'loop', 'page' ); ?>
    
    <!-- END .postarea middle -->
    </div>
    
    <!-- END .eight columns -->
    </div>
    
    <!-- BEGIN .four columns -->
    <div class="four columns">
    
    <?php get_sidebar(); ?>
    
    <!-- END .four columns -->
    </div>
    
    <!-- END .row -->
    </div>
    
    <!-- END .post class -->
    </div>
    <?php } ?>
    
    <!-- BEGIN .row -->
    <div class="row">
    
    <!-- BEGIN .sixteen columns -->
    <div class="sixteen columns">
    
    <!-- BEGIN .postarea full -->
    <div class="postarea full">
    
    <?php get_template_part( 'loop', 'page' ); ?>
    
    <!-- END .postarea full -->
    </div>
    
    <!-- END .sixteen columns -->
    </div>
    
    <!-- END .row -->
    </div>
    
    <?php get_footer(); ?>

    Change $level_id in the above code for the access level id for your bl level

    so it looks like

    <?php if(current_user_on_level( 1 )) { ?>

    Hope this helps

  • Matt

    This is my current code. Can you tell me why this isn't working? I have confirmed that 16 is the appropriate ID number for the BL user level. It's still showing the <div class="sixteen columns"> portion on all levels.

    <?php
    /**
    Template Name: APM Library
    *
    * @package Natural
    * @since Natural 3.0
    *
    */
    get_header(); ?>
    
    <?php /*<div id="featurebanner" align="center"><?php echo do_shortcode('[level-bl][bookshelf id="801" btn_titles="Titles" btn_icons="Icons" item_width="100%" item_height="240" products_box_margin_left="30" product_title_textcolor="#ffffff" product_title_bgcolor="#c33b4e" product_margin="30" product_show_title="true" show_title_in_popup="true" show_selected_title="true" show_icons="true" thumbs_effects="true" buttons_margin="15" buttons_align="center" slide_duration="1000" slide_easing="easeOutQuart" arrow_duration="800" arrow_easing="easeOutQuart" video_width="500" video_height="290" iframe_width="500" iframe_height="330" exclude_products="" orderby="modified" order="DESC" categories="apm-library" post_type="bookshelf"][/level-bl]');?></div>*/?>
    
    <?php if(current_user_on_level(16)) { ?>
    <div id="featurebanner" align="center">
    
    <?php echo do_shortcode('[bookshelf id="801" btn_titles="Titles" btn_icons="Icons" item_width="100%" item_height="240" products_box_margin_left="30" product_title_textcolor="#ffffff" product_title_bgcolor="#c33b4e" product_margin="30" product_show_title="true" show_title_in_popup="true" show_selected_title="true" show_icons="true" thumbs_effects="true" buttons_margin="15" buttons_align="center" slide_duration="1000" slide_easing="easeOutQuart" arrow_duration="800" arrow_easing="easeOutQuart" video_width="500" video_height="290" iframe_width="500" iframe_height="330" exclude_products="" orderby="modified" order="DESC" categories="apm-library" post_type="bookshelf"]'); ?>
    
    </div>
    <?php } ?>
    
    <!-- BEGIN .post class -->
    <div <?php post_class(); ?> id="page-<?php the_ID(); ?>">
    
    	<?php if ( has_post_thumbnail()) { ?>
    		<div class="feature-img banner shadow radius-full"><?php the_post_thumbnail( 'featured-large' ); ?></div>
    	<?php } ?>
    
    <?php if(current_user_on_level(16)) { ?>
    	<!-- BEGIN .row -->
    	<div class="row">
    
    		<!-- BEGIN .four columns -->
    		<div class="four columns">
    
    			<?php get_sidebar('left'); ?>
    
    		<!-- END .four columns -->
    		</div>
    
    		<!-- BEGIN .eight columns -->
    		<div class="eight columns">
    
    			<!-- BEGIN .postarea middle -->
    			<div class="postarea middle">
    
    				<?php get_template_part( 'loop', 'page' ); ?>
    
    			<!-- END .postarea middle -->
    			</div>
    
    		<!-- END .eight columns -->
    		</div>
    
    		<!-- BEGIN .four columns -->
    		<div class="four columns">
    
    			<?php get_sidebar(); ?>
    
    		<!-- END .four columns -->
    		</div>
    
    	<!-- END .row -->
    	</div>
    <?php } ?>
    
    <?php if(!current_user_on_level(16)) { ?>
    	<!-- BEGIN .row -->
    	<div class="row">
    
    		<!-- BEGIN .sixteen columns -->
    		<div class="sixteen columns">
    
    			<!-- BEGIN .postarea full -->
    			<div class="postarea full">
    
    				<?php get_template_part( 'loop', 'page' ); ?>
    
    			<!-- END .postarea full -->
    			</div>
    
    		<!-- END .sixteen columns -->
    		</div>
    
    	<!-- END .row -->
    	</div>
    <?php } ?>
    	<!-- END .post class -->
    </div>
    
    <?php get_footer(); ?>
  • Matt

    I am using both the shortcode and the template code "current_user_on_level" for restricting content on a single page/template. The shortcode works with no problems, but the template code seems to be ignored when using the "view site as" function.

    For example, when viewing the site as level "BL", the [level-bl] shortcode restricts content as it should, whereas if(current_user_on_level(16) does not. If I log in as a user who is specifically assigned to the BL level, however, both the shortcode and template code do what they should. This appears to be a bug with the "view site as" function of the plugin.

  • Matt

    I don't bring simple questions to you; I understand that. One of the reasons our Company bought into WPMU was because of the outstanding support we got with the membership plugin. After only a few months we decided to go pro and start using more plugins and since we have been extremely happy with our decision. However, recently the "go above and beyond" customer service that we have become accustom to expect from a fantastic organization has almost completely dried up, along with our patience. We understand, some support is above and beyond the level you can support on a day to day especially as a site becomes complex and at a certain point users should seek out outside support to which we have a team that can support our customization and upper-level support needs. I also understand I have a lot to learn when it comes to web-development and that is why I have our organization paying for quality products and service. WPMUDev being one of them. I take great pride in the site we have developed and have great expectations of where it might go. Over the last several weeks the support I have been getting seems like I am being pushed to the side... and as a customer, not very important. I realize that I am only one customer. Early on in our relationship it felt like I was the only one and the staff that were tasked to support went way above and beyond.

    I write this because I do need additional help. Your developers have a explicit knowledge of your plugins and it makes sense that I reach out to you all to provide direction and then additional support when our developers need it. We pay for and will continue to contribute pay for your services because of the amount of integration work that has been done to our site. If there is someone I should be speaking with directly I would love the opportunity to connect. I have multiple topics that remain open with poor support. I bought in, because of the statement you continue to advertise on your home page.

    Post a question about anything to do with
    Word Press or any WPMU DEV product and we'll
    be there to help you 24/7 with under and hour
    average response times

  • Vaughan

    Hi MAtt,

    Sorry for the delay, we have been extra busy lately.

    It could be possible that you could instead of doing it as you have done, instead create a different template part for each, so you would have your main single.php

    But then you could use get_template_part()

    https://codex.wordpress.org/Function_Reference/get_template_part

    So;

    <?php
    /**
    Template Name: APM Library
    *
    * @package Natural
    * @since Natural 3.0
    *
    */
    get_header(); ?>
    
    <?php
     /*<div id="featurebanner" align="center">
    <?php echo do_shortcode('[level-bl][bookshelf id="801" btn_titles="Titles" btn_icons="Icons" item_width="100%" item_height="240" products_box_margin_left="30" product_title_textcolor="#ffffff" product_title_bgcolor="#c33b4e" product_margin="30" product_show_title="true" show_title_in_popup="true" show_selected_title="true" show_icons="true" thumbs_effects="true" buttons_margin="15" buttons_align="center" slide_duration="1000" slide_easing="easeOutQuart" arrow_duration="800" arrow_easing="easeOutQuart" video_width="500" video_height="290" iframe_width="500" iframe_height="330" exclude_products="" orderby="modified" order="DESC" categories="apm-library" post_type="bookshelf"][/level-bl]');?>
    </div>*/
    ?>
    
    <?php if(current_user_on_level(16)) {
        get_template_part( 'members', 'level' );
    } else {
       get_template_part( 'normal', 'level' );
    } ?>

    So rather than messing with different shortcodes, you could create 2 part templates one for the members with the level 16 code you want, and the other for normal

    so you place all the level 16 code in a file called members-level.php

    and the non members in normal-level.php

    So now, if the members level is 16, it will basicly just do an include of that file.

    So you're then using a seperate template for your 16 columns view, and another 1 for the other view.

    Hope this helps

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.