Wow membership seriously messes up my homepage

Hi all,

Wow I installed the member ship plugin recently and set it up on a test site and its completely weirded out my homepage. Check it out:

http://www.pathwebdesign.co.uk/

I have a custom homepage template which pulls in pages into an array and spits them out with a featured image and excerpt:

<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
	<header class="entry-header">
		<h1 class="entry-title"><?php the_title(); ?></h1>
	</header><!-- .entry-header -->

	<div class="entry-content">
		<?php the_content(); wp_reset_query(); ?>

        <?php
		  $counter = 1;
		  $args=array(
		  'orderby' =>'rand',
		  'order' =>'asc',
		  'post_type' =>'page',
		  'post__in' => array(139,109,44,51),
		   );
		   $page_query = new WP_Query($args); ?>

		<?php while ($page_query->have_posts()) : $page_query->the_post(); ?>
			<?php if ($counter == 3 || $counter == 6 || $counter == 9 || $counter == 12 ) { ?>
            <div style="clear:left;" class="hp-section <?php the_ID(); ?>">
            <?php } else { ?>
            <div class="hp-section <?php the_ID(); ?>">
            <?php } ?>
                <h2><a href="<?php the_permalink();?>"><?php the_title();?></a></h2>
                <?php if ( has_post_thumbnail() ) { // the current post has a thumbnail ?>
                <a href="<?php the_permalink();?>"><?php the_post_thumbnail('hp-featured-page', array('class' => 'shadow')); ?></a>
                <?php } else { ?>
                <a href="<?php the_permalink();?>"><img class="shadow" src="<?php echo get_template_directory_uri(); ?>/images/hp-featured-default.jpg" title="Come on admin add this pages featured image!" /></a>
                <?php } ?>
                <?php the_excerpt(); ?>
                <?php $postid = get_the_ID(); if ( $postid==109 ) { ?>
                    <a class="readmore" href="<?php the_permalink();?>">Take the tour &rarr;</a>
                <?php } else if ( $postid==139 ) { ?>
                	<a class="readmore" href="<?php the_permalink();?>">Listen here &rarr;</a>
                <?php } else { ?>
                    <a class="readmore" href="<?php the_permalink();?>">Read more from our <?php the_title();?> page &rarr;</a>
                <?php } ?>
			</div>
		<?php $counter = $counter + 1; endwhile; ?>

	</div><!-- .entry-content -->
</article><!-- #post-<?php the_ID(); ?> -->

I have no idea whats going on as Ive set a "Free Member" level which is set to the Stranger setting. This allows all pages to be viewed by this member level.

What the hell is going on, why has it jumbled and duplicated areas of my homepage and displaying the become a member message?

  • ThePath

    Ive managed to partially fix it but only getting the register as a member message away from top of page. It is meant to look like the attached screenshot. Then you will see hoe messed up it still is.

    Must have something to do with my custom homepage or perhaps some membership settings.

    Im still not sure on the positive/negative rules. Seems a bit weird to me. For instance if I put pages in negative and check one page (so this one isnt accessed by a certain member level). Then I would expect the others to be visible but this doesnt seem to be the case completely.....as this is how I fixed the registration message issue above. Instead of having one page checked in negative I had to put pages in positive and check all but one page...

  • 3SixtyEvolve

    Hi ThePath

    Hope you're well.

    I've been looking at your site and can see that the membership content is also displaying on the home page - and of course it shouldn't. I will ask the Developer to have a quick look for you to see if he has any suggestions on this. I personally can't figure out how to avoid this from happening without seeing the whole setup in front of me.

    Allow me some time to get back to you. I believe there's just something small that needs to be adjusted, but I can't put my finger on what exactly.

    Great work, BTW.

    Talk soon!

    GinaB

  • Barry

    I even tried putting the member pages in post__not_in and still they are displayed

    That part of the WP_Query stopped working reliably in WP 3.2 I believe (I've certainly had a lot of sleepless nights trying to work out what it is and isn't doing), the membership plugin has that in as a backwards compatible bit of functionality but uses a different method now - I'll see if I can drag some code out for you.

  • Barry

    the question is why do membership pages thing they are better than the others and demand to be included

    because, if you have restricted everything from a non-member, then you *still* want them to be able to sign-up and give you money (so the registration and payment pages have to be able to be shown), or if the user was previously a member, then you want to be able to let them login, see their account and renew their membership (so you need to be able to see the account and renew pages).

  • ThePath

    Yeh but surely you restrict things from non members using the tools offered by the plugin.

    My homepage is just using a custom loop which essentially has no bearing on member/non-member.

    Obviously Im not getting the inner workings of the membership plugin (no wonder really...duh). Anyway whatever the reasons, still creates the question of, any solutions. Must have to do something creative with the query perhaps.

  • Barry

    Yeh but surely you restrict things from non members

    A non-member is the same as a member who hasn't logged in, so you have to assume that they may want to either register *or* access their account :slight_smile:

    You can restrict those pages from custom loops - but I need to dig out the code to do it :slight_smile: The new version of membership (which I've got on this laptop) uses a different method for things so I've got to dig in the older version.

  • ThePath

    I have done a simple solution just using and extra if:

    <?php $postid = get_the_ID(); if ( $postid==139 || $postid==109 || $postid==44 || $postid==51 ) { ?>

    Just had a sudden brain wave that you can just as easily block pages using an IF rather than make the query even more complex.

    Do you think this is the best solution or does it use more server resources and eat up more time?

    Still it works :smiley:

  • ThePath

    Haha Id ended the IF before the counter could iterate.

    OK just incase anybody comes across this and is doing the same thing here is complete code:

    <article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
    	<header class="entry-header">
    		<h1 class="entry-title"><?php the_title(); ?></h1>
    	</header><!-- .entry-header -->
    
    	<div class="entry-content">
    		<?php the_content(); wp_reset_query(); rewind_posts(); ?>
    
            <?php
    		  $counter = 1;
    		  $args=array(
    		  'orderby' =>'rand',
    		  'order' =>'asc',
    		  'post_type' =>'page',
    		  'post__in' => array(139,109,44,51)
    		   );
    		   $page_query = new WP_Query($args); ?>
    
    		<?php while ($page_query->have_posts()) : $page_query->the_post(); ?>
            <?php  $postid = get_the_ID(); if ( $postid==139 || $postid==109 || $postid==44 || $postid==51 ) {  ?>
    			<?php if ($counter == 3 || $counter == 6 || $counter == 9 || $counter == 12 ) { ?>
                <div style="clear:left;" class="hp-section <?php the_ID(); ?>">
                <?php } else { ?>
                <div class="hp-section <?php the_ID(); ?>">
                <?php } ?>
                    <h2><a href="<?php the_permalink();?>"><?php the_title();?></a></h2>
                    <?php if ( has_post_thumbnail() ) { // the current post has a thumbnail ?>
                    <a href="<?php the_permalink();?>"><?php the_post_thumbnail('hp-featured-page', array('class' => 'shadow')); ?></a>
                    <?php } else { ?>
                    <a href="<?php the_permalink();?>"><img class="shadow" src="<?php echo get_template_directory_uri(); ?>/images/hp-featured-default.jpg" title="Come on admin add this pages featured image!" /></a>
                    <?php } ?>
                    <?php the_excerpt(); ?>
                    <?php if ( $postid==109 ) { ?>
                        <a class="readmore" href="<?php the_permalink();?>">Take the tour &rarr;</a>
                    <?php } else if ( $postid==139 ) { ?>
                    	<a class="readmore" href="<?php the_permalink();?>">Listen here &rarr;</a>
                    <?php } else { ?>
                        <a class="readmore" href="<?php the_permalink();?>">Read more from our <?php the_title();?> page &rarr;</a>
                    <?php } ?>
    			</div>
    		<?php $counter = $counter + 1; } endwhile; ?>
    
    	</div><!-- .entry-content -->
    </article><!-- #post-<?php the_ID(); ?> -->

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.