Odd permissions

I am experiencing some odd behavior on the membership levels.

I have two levels - Free and Subscriber.

Free only has access to a very limited portion of the site. This is done through the use of both categories and shortcodes in the level area.

Subscriber should have access to the entire site, again through the use of categories and short codes. This is also tied to the Wordpress Subscriber role.

I have four category boxes on my home page. Each is set to display a post from a different category.

When a non-logged in user (stranger) visits the site each category box will display a post from that category.

When a "Subscriber" user (logged in) visits the site each category box will display a post from the same category. It is always the last post in the database. This is not what it should do. It should display a different post from each category. The posts do not overlap categories.

Additionally, if I browse directly to the category via url (when logged in as subscriber) I am able to access all of the content.

When the admin visits the site it displays a post from each different category.

When I turn off membership plugin it works as expected.

So it seems that there is something in the plugin that is causing this behavior. I haven't dug into the plugin code but it seems that it is altering the query_posts function in someway that is not recognizing the appropriate membership level.

Any help would be appreciated.

Thanks.

  • Philip John

    Hiya,

    I have four category boxes on my home page. Each is set to display a post from a different category.

    First off, how is this done? I presume multiple loops in your theme's home.php?

    When a "Subscriber" user (logged in) visits the site each category box will display a post from the same category. It is always the last post in the database. This is not what it should do. It should display a different post from each category.

    If the boxes are set up with a loop in each one, displaying a different category, Membership's rules will not be able to change the behaviour of that loop (i.e. by showing different categories/posts).

    It'd help if you could provide screenshots and/or more detailed explanations about what you'd like to achieve then we can make sure you're doing it the right way :slight_smile:

    Cheers!
    Phil

  • adamsmall

    This is how the category boxes are created.

    Regarding the code: I have verified that the $cat_option is returning the correct category number (also evidenced by the fact that it works as admin).

    Additionally, the level permissions are set by category in the membership plugin.

    <?php if (get_option('whoswho_show_catboxes') == 'on') { ?>
    	<!--Category Box 1-->
    	<?php $cat_option='whoswho_home_cat_one'; ?>
    	<?php query_posts("showposts=1&cat=".get_catId(get_option($cat_option)));
    		  while (have_posts()) : the_post(); ?>
    		  <?php //echo get_catId(get_option($cat_option)); ?>
    			  <?php include(TEMPLATEPATH . '/includes/category_box.php'); ?>
    	<?php endwhile; wp_reset_query(); ?>
    	<!--End Category Box 1-->
    
    	<!--Category Box 2-->
    	<?php $cat_option='whoswho_home_cat_two'; ?>
    	<?php query_posts("showposts=1&cat=".get_catId(get_option($cat_option)));
    		  while (have_posts()) : the_post(); ?>
    		  <?php //echo get_catId(get_option($cat_option)); ?>
    			  <?php include(TEMPLATEPATH . '/includes/category_box.php'); ?>
    	<?php endwhile; wp_reset_query(); ?>
    	<!--End Category Box 2-->
    
    	<div style="clear: both;"></div>
    
    	<!--Category Box 3-->
    	<?php $cat_option='whoswho_home_cat_three'; ?>
    	<?php query_posts("showposts=1&cat=".get_catId(get_option($cat_option)));
    		  while (have_posts()) : the_post(); ?>
    		  <?php //echo get_catId(get_option($cat_option)); ?>
    			  <?php include(TEMPLATEPATH . '/includes/category_box.php'); ?>
    	<?php endwhile; wp_reset_query(); ?>
    	<!--Category Box 3-->
    
    	<!--Category Box 4-->
    	<?php $cat_option='whoswho_home_cat_four'; ?>
    	<?php query_posts("showposts=1&cat=".get_catId(get_option($cat_option)));
    		  while (have_posts()) : the_post(); ?>
    		  <?php //echo get_catId(get_option($cat_option)); ?>
    			  <?php include(TEMPLATEPATH . '/includes/category_box.php'); ?>
    	<?php endwhile; wp_reset_query(); ?>
    	<!--Category Box 4-->
    	<!--End category boxes-->
    <?php }; ?>

    category_box.php

    <?php $thumb = '';
    	  $width = 70;
    	  $height = 70;
    	  $classtext = 'catbox_image';
    	  $titletext = get_the_title();
    
    	  $thumbnail = get_thumbnail($width,$height,$classtext,$titletext,$titletext);
    	  $thumb = $thumbnail["thumb"]; ?>
    
    <div class="home-categories">
    	<span class="headings"><?php echo(get_option($cat_option)); ?></span>
    	<a href="<?php the_permalink(); ?>">
    		<?php the_title(); ?>
    	</a>
    	<div style="clear:both;"></div>
    
    	<?php if($thumb != '') { ?>
    		<a href="<?php the_permalink() ?>" title="<?php printf(__('Permanent Link to %s','WhosWho'), get_the_title()) ?>">
    			<?php print_thumbnail($thumb, $thumbnail["use_timthumb"], $titletext , $width, $height, $classtext); ?>
    		</a>
    	<?php } ?>
    	<?php truncate_post(310) ?>
    	<div style="clear:both;"></div>
    </div>

    Screen Shots are attached.
    The admin screen shot is accurate and what I expect the Subscriber to see when they login. Instead they see the same post in all 4 boxes.

    The Stranger screen shot is almost right. It shows top right and the bottom left accurately, with the title visible and the "subscriber only" message. But the top left and the bottom right are duplicates, so not quite right. This should look like the admin except with the "subscriber only" message instead of the actual detail.

    Admin

    Subscriber

    Stranger

  • Philip John

    Hmm okay, that's clearer.

    Can you tell me the values of each of the options please;
    - whoswho_show_catboxes
    - whoswho_home_cat_one
    - whoswho_home_cat_two
    - whoswho_home_cat_three
    - whoswho_home_cat_four

    Screenshots of the levels would also help. Or if you're comfortable with it, you can send me a login to your site using the contact form (put "ATTN Phil" in the subject) and I'll look directly.

    Phil

  • Philip John

    Okay, here we go...

    The reason "B-Aware Subscribers" is appearing in there is because you have it in the Blog category as well as "Fishers, IN" category. Remove it from the blog category and it will no longer show to strangers.

    With the subscribers view it seems as though the category is actually being ignored and every loop is simply returning the 'latest' post. This is confused by the latest posts having the same timestamp.

    Try echoing the value of the category variable to test it is set properly like so;
    <?php $cat_option='whoswho_home_cat_two'; echo "<!-- $cat_option -->"; ?>

    It might be worth doing the same with the query;

    $yourquery = "showposts=1&cat=".get_catId(get_option($cat_option));
    echo "<!-- $yourquery -->";
    query_posts($yourquery);

    Cheers!
    Phil

  • adamsmall

    Phil,

    I get the stranger view duplicate issue, I should have caught that myself.

    As for echoing the category values, I have done this and each category properly reflects the category value when logged in as Stranger, Admin, and Subscriber. They are also consistent across the board, meaning that each category id is the same no matter what type of account I am logged in as.

    The same goes for the query; each query is properly querying a different category.

    I left the commented code in the page if you would like to look at it.

    But the problem remains. Stranger View and Admin View are correct but the subscriber view is only showing the last post. The only way to correct this is to turn off the membership plugin.

  • adamsmall

    Mason,

    I have sent a link with login credentials through the contact form. It was attention to Phil.

    The issue is that depending on the subscriber level the loop isn't properly displaying posts.

    Stranger and Admin appear to display posts accurately, with protected content working based on the level. However a logged in user who is not an Admin only sees the last post as opposed to posts from different categories. See images above for reference.

    In the short term I have hidden the category boxes if the user is logged in. I can comment out the hide code to allow them to be visible and more accurately show the issue. Please let me know.

    Thanks,

    Adam

  • DavidM

    Hi Adam,

    I'm taking a look at this as well as Phil and Mason. We're working to get this sorted for ya as quickly as possible and we do appreciate all your patience!

    And to get a better gauge of a few things, could you download a fresh copy of the latest version 2.0.3 of Membership? It has a few fixes and a few things that will help us rule out a few trouble points.
    https://premium.wpmudev.org/project/membership

    Could you give that an install and let us know if that fixes things off-hand?

    Thanks,
    David

  • DavidM

    Hi Adam,

    In taking a close look at your rule setup for the Subscriber level I realized you had all of the categories and shortcodes ticked and the rules were in the positive area. Given my understanding from what you've said, the Subscriber should technically see exactly what the Admin sees, correct? If so, the Subscriber wouldn't need any rules specified at all.

    Given that, I've removed all the rules from the Subscriber level and testing it, the Subscriber account does appear to see exactly what you've said should be seen. Could you please take a look and verify that?

    Thanks,
    David

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.