• Resolved rafaela3r

    (@rafaela3r)


    Hi there,
    I’m building a website with x theme and paid membership pro.
    I can restrict the view for pages and posts but not if the layout is “portfolio”
    Can you help me ? Thanks

    • This topic was modified 3 years, 7 months ago by rafaela3r.

    The page I need help with: [log in to see the link]

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Support Kim White

    (@kimwhite)

    Hello!

    Thank you for using Paid Memberships Pro.

    It sounds like your portfolio pages may be Custom Post Types (CPT)
    Can you clarify the problem, is the “Require Membership” meta box appearing on the right, or is it there, but not working to protect the page?

    Here is a guide to add the restricted metabox to these pages – https://www.paidmembershipspro.com/restrict-access-by-membership-level-for-custom-post-type-cpt-categories/

    The code recipe is freely available on gist.github.com under the same title/keywords.

    If the the metabox is visible but not restricting your content the template page may not be written correctly to work with our plugin. Can you tell me the theme you are using?

    I hope this helps, please let me know if you have any further questions.

    Kim W

    Thread Starter rafaela3r

    (@rafaela3r)

    Hi Kim,
    Thanks for your answer ??

    In my case the metabox is visible but not restricting the content. I’m using X pro theme.

    ??

    here is the code of the portfolio template…

    <?php
    
    // =============================================================================
    // VIEWS/GLOBAL/_PORTFOLIO.PHP
    // -----------------------------------------------------------------------------
    // Includes the portfolio output.
    // =============================================================================
    
    $stack    = x_get_stack();
    $entry_id = get_the_ID();
    
    global $sitepress;
    
    if ( function_exists( 'icl_object_id' ) && is_callable( array( $sitepress, 'get_current_language' ) ) ) {
    	$wpml_post = get_post( icl_object_id( $entry_id, 'page', false, $sitepress->get_current_language() ) );
    	$entry_id  = $wpml_post->ID;
    }
    
    $paged   = ( is_front_page() ) ? get_query_var( 'page' ) : ( ( get_query_var( 'paged' ) ) ? get_query_var( 'paged' ) : 1 );
    $cols    = get_post_meta( $entry_id, '_x_portfolio_columns', true );
    $count   = get_post_meta( $entry_id, '_x_portfolio_posts_per_page', true );
    $filters = get_post_meta( $entry_id, '_x_portfolio_category_filters', true );
    
    if ( ! $filters ) {
      $filters = array();
    }
    
    switch ( $cols ) {
      case 'One'   : $cols = 1; break;
      case 'Two'   : $cols = 2; break;
      case 'Three' : $cols = 3; break;
      case 'Four'  : $cols = 4; break;
    }
    
    ?>
    
    <?php x_get_view( 'global', '_script', 'isotope-portfolio' ); ?>
    
    <div id="x-iso-container" class="x-iso-container x-iso-container-portfolio cols-<?php echo $cols; ?>">
    
      <?php
    
      if ( count( $filters ) == 1 && in_array( 'All Categories', $filters ) ) {
    
        $args = array(
          'post_type'      => 'x-portfolio',
          'posts_per_page' => $count,
          'paged'          => $paged
        );
    
      } else {
    
        $args = array(
          'post_type'      => 'x-portfolio',
          'posts_per_page' => $count,
          'paged'          => $paged,
          'tax_query'      => array(
            array(
              'taxonomy' => 'portfolio-category',
              'field'    => 'term_id',
              'terms'    => $filters
            )
          )
        );
    
      }
    
      $wp_query = new WP_Query( $args );
    
      ?>
    
      <?php if ( $wp_query->have_posts() ) : ?>
        <?php while ( $wp_query->have_posts() ) : $wp_query->the_post(); ?>
          <?php if ( $stack != 'ethos' ) : ?>
            <?php x_get_view( $stack, 'content', 'portfolio' ); ?>
          <?php else : ?>
            <?php x_ethos_entry_cover( 'main-content' ); ?>
          <?php endif; ?>
        <?php endwhile; ?>
      <?php endif; ?>
    
    </div>
    
    <?php pagenavi(); ?>
    <?php wp_reset_query(); ?>
    Plugin Author Andrew Lima

    (@andrewza)

    For this, you should be able to use the function pmpro_hasMembershipLevelhttps://www.paidmembershipspro.com/documentation/content-controls/require-membership-function/

    This function may be used directly in your theme’s page template (referenced above) and returns true or false if the user has an active level or not. If they don’t have an active level, you then can show a custom restricted message.

    If you need help tweaking this further, please reach out to a local WordPress developer.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘x theme portfolio template’ is closed to new replies.