Community Support Forums — WordPress® ( Users Helping Users ) — 2011-09-16T07:40:48-05:00 http://www.primothemes.com/forums/feed.php?f=4&t=14240 2011-09-16T07:40:48-05:00 http://www.primothemes.com/forums/viewtopic.php?t=14240&p=37306#p37306 <![CDATA[Re: Members only latest posts page]]> Statistics: Posted by Terry — September 16th, 2011, 7:40 am


]]>
2011-08-03T22:55:08-05:00 http://www.primothemes.com/forums/viewtopic.php?t=14240&p=29795#p29795 <![CDATA[Re: Members only latest posts page]]>

Statistics: Posted by Cristián Lávaque — August 3rd, 2011, 10:55 pm


]]>
2011-08-03T10:01:58-05:00 http://www.primothemes.com/forums/viewtopic.php?t=14240&p=29754#p29754 <![CDATA[Re: Members only latest posts page]]> Thanks for the reply, that was exactly what I needed!

It's taken a bit of work but I have managed to get it working, below is a solution if anyone has the same problem when building a them:

Code:

<?php 
        $sticky_top 
= get_option( 'sticky_posts' );
        $res_1 = $GLOBALS['WS_PLUGIN__']['s2member']['o'][level0_posts];
        $OutputArray2 = explode(",", $res_1);
        rsort( $OutputArray2 );
        rsort($sticky_top);
        $ArrayCount = 0;
        foreach ($OutputArray2 as $OutputArray2ArrayElement){
            if($OutputArray2ArrayElement <> ""){
                foreach ($sticky_top as $sticky_topArrayElement){
                    if($sticky_topArrayElement <> "" && $OutputArray2ArrayElement == $sticky_topArrayElement){
                        $MemberSticky[$ArrayCount] = $OutputArray2ArrayElement;
                        $CurrentSticky = $OutputArray2ArrayElement;
                        $ArrayCount ++;
                        break 2;
                    }
                };
            }
        };
        
        $args 
= array(
        'posts_per_page' => 1,
        'post__in'  => $MemberSticky,
        'ignore_sticky_posts' => 1
        
);

        query_posts( $args );?>
         <?php rewind_posts(); ?>
        
          <?php while (have_posts()) : the_post(); ?>
      <h1><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>">
        <?php the_title(); ?>
        </a></h1>
      <br />
      <?php 
        if 
( has_post_thumbnail() ) {
            echo '<div class="homepost_thumbnail">';
            the_post_thumbnail();
            echo '</div>';
        } 
        the_excerpt
('Read more &raquo;'); ?>
     <?php endwhile; ?>


In english, this code is getting all sticky posts using the variable
Code:
$sticky_top = get_option( 'sticky_posts' );


Using the Globals from Cristián, I have selected only level 0 posts to be shown (as I will have different dashboards for each member level if an when we chose to implement it. Therefore the variable here is
Code:
$res_1 = $GLOBALS['WS_PLUGIN__']['s2member']['o'][level0_posts];


Code:
$OutputArray2 = explode(",", $res_1);
"explodes" the $Globals into an array.

In order to get the chronological order of the posts I have used:
Code:
rsort( $OutputArray2 );
rsort($sticky_top);


Now for the actual work:
I create a counter
Code:
$ArrayCount = 0;
, this is so the array produced by the following code will start its array at 0.

In order to decide which one of the values in $res_1 (now $OutputArray2) is the latest sticky post we need to separate each individual variable from the array and see if it is equal to each individual element of the $sticky_top array.
The first part of this is to separate $OutputArray2:

Code:
foreach ($OutputArray2 as $OutputArray2ArrayElement) {


We need to check if $OutputArray2ArrayElement has a value
Code:
if($OutputArray2ArrayElement <> ""){
if so then separate out the sticky post array ($sticky_top):

Code:
foreach ($sticky_top as $sticky_topArrayElement){


Again, check if there is actually an object in the array element "$sticky_topArrayElement" with the if statement:
Code:
if($sticky_topArrayElement <> ""
And now that our array elements are separated out, see if the one element is equal to another:
Code:
&& $OutputArray2ArrayElement == $sticky_topArrayElement){


This will loop through the foreach statement and output every element that is equal to the top element, each time it finds and element it outputs it and adds 1 to the $ArrayCount.
This information is currently useless as it is not in a variable (specifically an array object as WordPress will not accept anything other than an array for 'post__in').

So, the above is done by putting it into a variable:
Code:
$MemberSticky[$ArrayCount] = $OutputArray2ArrayElement;
and adding to the $ArrayCount
Code:
$ArrayCount ++;


We then close the foreach loops with
Code:
break 2;
so that we don't leave it continuously running! All lose ends are closed off with a "}" and we move on to WordPress's Loop:

All of the arguments needed for The Loop are stored in the array "$args" as so:
Code:
$args = array(
        'posts_per_page' => 1,
        'post__in'  => $MemberSticky,
        'ignore_sticky_posts' => 1
);


$MemberSticky is the result of our efforts in the foreach loop. Wordpress is going to only show one post, from the $MemberSticky array and check if it's sticky (technically we don't need this as we've already decided it's sticky!).

Next run the query
Code:
query_posts( $args );?>
and do the standard
Code:
<?php while (have_posts()) : the_post(); ?>


All the stuff in between goes here (i.e. title, the content etc.) then close the while
Code:
<?php endwhile; ?>


You will notice in the big block of code at the top, two items "$CurrentSticky = $OutputArray2ArrayElement;" and
Code:
<?php rewind_posts(); ?>
. The reason for the "rewind_posts" is because I want to do another loop on the page, and the $CurrentSticky variable is used in my next loop.
The next loop displays all s2Member level 0 posts, excluding the sticky post above. I won't go into more detail, but the whole template page is attached dashboard-page.txt

Hope this saves people time and they find it useful! Thanks again Cristián

Terry

Statistics: Posted by Terry — August 3rd, 2011, 10:01 am


]]>
2011-07-27T00:34:11-05:00 http://www.primothemes.com/forums/viewtopic.php?t=14240&p=29242#p29242 <![CDATA[Re: Members only latest posts page]]>

You can check what content is protected looking at these:

Code:
$GLOBALS['WS_PLUGIN__']['s2member']['o'][level0_ruris]
$GLOBALS['WS_PLUGIN__']['s2member']['o'][level1_ruris]
$GLOBALS['WS_PLUGIN__']['s2member']['o'][level2_ruris]
$GLOBALS['WS_PLUGIN__']['s2member']['o'][level3_ruris]
$GLOBALS['WS_PLUGIN__']['s2member']['o'][level4_ruris]
$GLOBALS['WS_PLUGIN__']['s2member']['o'][level0_catgs]
$GLOBALS['WS_PLUGIN__']['s2member']['o'][level1_catgs]
$GLOBALS['WS_PLUGIN__']['s2member']['o'][level2_catgs]
$GLOBALS['WS_PLUGIN__']['s2member']['o'][level3_catgs]
$GLOBALS['WS_PLUGIN__']['s2member']['o'][level4_catgs]
$GLOBALS['WS_PLUGIN__']['s2member']['o'][level0_ptags]
$GLOBALS['WS_PLUGIN__']['s2member']['o'][level1_ptags]
$GLOBALS['WS_PLUGIN__']['s2member']['o'][level2_ptags]
$GLOBALS['WS_PLUGIN__']['s2member']['o'][level3_ptags]
$GLOBALS['WS_PLUGIN__']['s2member']['o'][level4_ptags]
$GLOBALS['WS_PLUGIN__']['s2member']['o'][level0_posts]
$GLOBALS['WS_PLUGIN__']['s2member']['o'][level1_posts]
$GLOBALS['WS_PLUGIN__']['s2member']['o'][level2_posts]
$GLOBALS['WS_PLUGIN__']['s2member']['o'][level3_posts]
$GLOBALS['WS_PLUGIN__']['s2member']['o'][level4_posts]
$GLOBALS['WS_PLUGIN__']['s2member']['o'][level0_pages]
$GLOBALS['WS_PLUGIN__']['s2member']['o'][level1_pages]
$GLOBALS['WS_PLUGIN__']['s2member']['o'][level2_pages]
$GLOBALS['WS_PLUGIN__']['s2member']['o'][level3_pages]
$GLOBALS['WS_PLUGIN__']['s2member']['o'][level4_pages] 


I hope it helps.

Statistics: Posted by Cristián Lávaque — July 27th, 2011, 12:34 am


]]>
2011-07-26T07:59:02-05:00 http://www.primothemes.com/forums/viewtopic.php?t=14240&p=29176#p29176 <![CDATA[Members only latest posts page]]> First of all, thank you for such an excellent plugin! s2Member has been a fantastic addition to the site and I am extremely happy with it!
I have most of it setup, and am currently hitting a wall on how to display member only posts in the loop of a template page. I would say I am intermediate at theme creation in wp, and have created a widget in order to display a different message to members and non-members (e.g. subscribe to one and login to the other).

I know the easy way would be to display posts of a specific members only category e.g. Premium Content.
However, we will have many Authors contributing to the site within the company, and therefore I expect there will be a few that will find it difficult to adhere to the rule of posting premium content in the "Premium Content" category (as obvious as that sounds :roll: )!

With this in mind, I need to create a more dynamic method. Below is an example of the code I am using for the home-page.php
Code:
<div id="main">
  <div id="left_column">
    <div class="left_col_box"> <span class="main_titles">Featured Content</span>
      <?php $args = array(
    
'posts_per_page' => 1,
    
'post__in'  => get_option'sticky_posts' ),
    
'ignore_sticky_posts' => 1
);
query_posts$args );?>
      <?php rewind_posts(); ?>
      <?php while (have_posts()) : the_post(); ?>
      <h1><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>">
        <?php the_title(); ?>
        </a></h1><br />

      <?php the_content('Read more &raquo;'); ?>
      <br /><div class="post_details">
 by <?php the_author() ?> Date: <time datetime="<?php the_time('Y-m-d'?>" pubdate="<?php the_time('F jS, Y'?>"><?php the_time('F jS, Y'?></time>
        <br/>
        Posted in
        <?php the_category(', '?>
        | <?php the_tags('Tags: '', ''<br />'); ?>
        <?php edit_post_link('Edit'''' | '); ?></div>
      <div class="clear"></div>

    </div>
    <?php endwhile; ?>
    <div class="left_col_box"> <span class="main_titles">Recent Content</span>
      <?php

// The Query
query_posts( array('posts_per_page=5','ignore_sticky_posts' => 1) );

// The Loop
while ( have_posts() ) : the_post(); ?>
      <h2 style="margin-bottom: 0px;"><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>">
        <?php the_title(); ?>
        </a></h2>
      <div class="post_details">
        
        by <?php the_author() ?> Date: <time datetime="<?php the_time('Y-m-d'?>" pubdate="<?php the_time('F jS, Y'?>"><?php the_time('F jS, Y'?></time>
        <br/>
        Posted in
        <?php the_category(', '?>
        | <?php the_tags('Tags: '', ''<br />'); ?>
        <?php edit_post_link('Edit'''' | '); ?>
        
      </div>
      <?php endwhile;

// Reset Query
wp_reset_query();

?>
    </div>
  </div>
  <div id="right_column">
 <?php if ( is_active_sidebar'rcb-widget-area' ) ) : ?>

            <div class="right_col_box"> 
                <?php dynamic_sidebar'rcb-widget-area' ); ?>
            </div>

<?php endif; ?>
    
  </div>
</div>


This will show any user (logged in or not) all posts with a featured on the top, and a list on the bottom. I want to create the same layout only with Featured Premium Post on the top and Latest Premium Content on the bottom. I am hoping the answer will be something simple like:

Code:
<?php $args = array(
    
'posts_per_page' => 1,
    
'post__in'  => get_option's2member_posts' ),
    
'ignore_sticky_posts' => 1
);
query_posts$args );?>
      <?php rewind_posts(); ?>
      <?php while (have_posts()) : the_post(); ?>


Alas, I expect it will be something a bit more challenging!
Thank you in advance for your help and I hope I haven't rambled too much!

Statistics: Posted by Terry — July 26th, 2011, 7:59 am


]]>