• Firstly – thank you for a wonderful plugin.
    I have reviewed many membership plugins and this one stands out head and shoulders above the rest.

    I am trying to protect all content unless a user is logged in.
    My default settings are pages & posts protected + not showing excerpts.
    This works well for all pages that do not use custom templates…

    However I have two pages using custom page templates and the privacy is simply overridden. I delved into the template page code and was able to make the login appear by including <?php the_content(); ?> but then the custom page template content is displayed below this.

    If I use the custom field switch for just that page, I can get the login to appear and disappear depending on the switch used but the page content is ignored.

    I guess this is related to the loop and how my page template is structured.
    Any advice on how to set this up correctly with a custom page template?

    https://www.ads-software.com/extend/plugins/wp-members/

Viewing 9 replies - 1 through 9 (of 9 total)
  • I have a similar issue, using a custom WP_Query in a custom page template.

    If I remove the custom query code and leave the usual if ( have_posts() ) stuff in – it works fine. Has anyone else seen behaviour like this?

    Thanks.

    Plugin Author Chad Butler

    (@cbutlerjr)

    @seanpre – that’s an interesting dilemma.

    Do the custom templates display multiple posts or single?

    The plugin is designed to filter the contents returned by the_content, so if you are using the Loop to display, it should function normally.

    How is the content being delivered to the template?

    If these templates show multiple posts, are you using the ‘more’ tag?

    Plugin Author Chad Butler

    (@cbutlerjr)

    @spectrus – the plugin is designed as a filter for the_content. If you use wp_query outside the loop to deliver the content, the plugin doesn’t know to protect it.

    If this is something that is relatively static, the solution might be to go a step further and use is_user_logged_in. Something like:

    <?php
    if( is_user_logged_in() ) {
    
    	// user is logged in
    	// do your wp_query here...
    
    } else {
    
    	// user is not logged in
    	// display something else
    
    }
    ?>
    Thread Starter seanpre

    (@seanpre)

    Thanks for the reply Chad.

    The two page templates are not displaying multiple posts or pages.
    The one is an order form which has form elements linking to custom fields and some jQuery to handle the price calculations on the fly.
    The other is a booking form, so both are serving their own unique content from within the respective template.

    I used your suggestion above and it works thank you.
    I put all the necessary code in a 3rd file and call this with an include if the user is logged in, if not I display the_content so your login form is displayed.

    <?php
    if ( is_user_logged_in() ) {
        include "bookings-calculation.php";
    } else {
         the_content();
    }
    ?>
    Plugin Author Chad Butler

    (@cbutlerjr)

    Glad that is working out! And thanks for posting this because I know there are others out there doing similar things. It’s good to have some examples out there.

    Thank you very much Chad, I take off my hat to you for such speedy responses on this board.

    I fixed it by altering your code sample to the following:

    <?php
    if( is_user_logged_in() ) {
    
    	// my wp_query here...
    
    } else {
        if (function_exists('wpmem_securify'))
        {
            // display loging prompt as on other pages
            echo '<h1 class="entry-title">' . get_the_title() . "</h1>";
            wpmem_securify();
            the_content();
        }
    }
    ?>
    Plugin Author Chad Butler

    (@cbutlerjr)

    That’s good stuff… thanks!

    Plugin Author Chad Butler

    (@cbutlerjr)

    Thanks for helping fine tune this. I’ve been getting this question in various formats quite a bit lately, so I put this together in a specific ‘how-to’ kind of post.

    Thread Starter seanpre

    (@seanpre)

    wow! – great feedback and support Chad.

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘[Plugin: WP-Members] custom page template issue’ is closed to new replies.