Community Support Forums — WordPress® ( Users Helping Users ) — 2010-09-13T04:13:56-05:00 http://www.primothemes.com/forums/feed.php?f=4&t=691 2010-09-13T04:13:56-05:00 http://www.primothemes.com/forums/viewtopic.php?t=691&p=3205#p3205 <![CDATA[Re: Hiding protected posts]]> I created a simple condition:
Code:
<?php if(in_category(3) && is_user_not_logged_in()){ ?>

where "3" is my protected category. I did not find the eventual function used by S2member to get the protected categories ID. Does it exist ?

Statistics: Posted by camillemm — September 13th, 2010, 4:13 am


]]>
2010-09-09T10:40:03-05:00 http://www.primothemes.com/forums/viewtopic.php?t=691&p=3099#p3099 <![CDATA[Re: Hiding protected posts]]> Thanks for reporting back.
Sure. You might want to steer your developer into the direction of s2Member's API Scripting section.
In your Dashboard, see: s2Member -> API Scripting -> Query Conditionals

Hope this helps. Please keep us posted if you can.
~ Much appreciated.

Statistics: Posted by Jason Caldwell — September 9th, 2010, 10:40 am


]]>
2010-09-09T08:27:34-05:00 http://www.primothemes.com/forums/viewtopic.php?t=691&p=3089#p3089 <![CDATA[Re: Hiding protected posts]]> For the single.php file, I did not manage (even on the test site :-)) to make it work. For the moment, I stop searching. I have contacted a plugin creator who made a "hide category to non connected people" plugin and I hope he will find a trick to make it works with S2member :-)
Last solution: changing the theme (aarrr !)

Statistics: Posted by camillemm — September 9th, 2010, 8:27 am


]]>
2010-09-09T05:07:06-05:00 http://www.primothemes.com/forums/viewtopic.php?t=691&p=3086#p3086 <![CDATA[Re: Hiding protected posts]]>
camillemm wrote:
After reading the options of Alternative View, it seems it's the opposite of my wish :-) because I want to hide the protect post in home and single view but show their existence in all the other views.

Gotchya. So you DO want to enable Alternative View Protection, but ONLY on your Home Page and/or in special queries inside single.php. So here is what I recommend, please report back on this if you can.

1. Alternative View Protection = off
2. Use attach_s2member_query_filters() and detach_s2member_query_filters()
Please note that in order for these to work, you MUST call upon query_posts() after you attach the filters. In your example of single.php, this is not the case. So you'll need to work some magic using something like the following example, being careful not to affect the wrong parts of your theme at the wrong time.

Code:

global $query_string
;
attach_s2member_query_filters();
/* Now re-query -> */ query_posts($query_string);

while (have_posts()): the_post();
     ... something, something
endwhile;

wp_reset_query();
detach_s2member_query_filters();
 

Make sure you're logged OUT whenever you test this. Also be sure that you've protected some content first, and that you're performing a query that would actually result in something being filtered.
This can be a little tricky at times ( depending on pagination, the specific archive view, etc ).

* NOTE: the home page sample you sent over, looks to me like it should be working as expected.
* NOTE: Make sure that your queries do NOT have this in the query string:
query_posts("suppress_filters=true");

Related article on query_posts()
[ http://codex.wordpress.org/Function_Ref ... uery_posts ]

Statistics: Posted by Jason Caldwell — September 9th, 2010, 5:07 am


]]>
2010-09-09T04:24:39-05:00 http://www.primothemes.com/forums/viewtopic.php?t=691&p=3085#p3085 <![CDATA[Re: Hiding protected posts]]> Statistics: Posted by camillemm — September 9th, 2010, 4:24 am


]]>
2010-09-08T02:16:00-05:00 http://www.primothemes.com/forums/viewtopic.php?t=691&p=3050#p3050 <![CDATA[Re: Hiding protected posts]]> it seems I cannot make it work with the code you gave me Elizabeth.
Here is my single.php
Code:
<?php
get_header();
attach_s2member_query_filters();
if (have_posts()) :
   while (have_posts()) : the_post();
      if (comicpress_in_comic_category()) {
         if (!comicpress_themeinfo('disable_comic_blog_single')) {
            comicpress_display_post();
            $cur_date = mysql2date('Y-m-j', $post->post_date);
            $next_comic = comicpress_get_next_comic();
            if (!empty($next_comic)) {
               $next_comic = (array)$next_comic;
               $next_date = mysql2date('Y-m-j', $next_comic['post_date']);
            }
            $blog_query = 'showposts='.comicpress_themeinfo('blog_postcount').'&order=asc&cat='.comicpress_exclude_comic_categories();
         }
      } else {
         comicpress_display_post();
      }
      comments_template('', true);
      
   endwhile;

   
   if (is_active_sidebar('blog')) get_sidebar('blog');
   
   if (comicpress_themeinfo('static_blog') && comicpress_in_comic_category()) {
      if (!comicpress_themeinfo('split_column_in_two')) {
         $blog_query = 'showposts='.comicpress_themeinfo('blog_postcount').'&cat='.comicpress_exclude_comic_categories().'&paged='.$paged;
         
         $posts = &query_posts($blog_query);
      if (have_posts()) { ?>
      
         <?php if (!comicpress_themeinfo('disable_blogheader')) { ?>
            <div id="blogheader"><!-- This area can be used for a heading above your main page blog posts --></div>
         <?php } ?>
         
         <div class="blogindex-head"></div>
         <div class="blogindex">
            <?php while (have_posts()) : the_post();
               
               comicpress_display_post();   
            
         endwhile; ?>
         </div>
         <div class="blogindex-foot"></div>
         <?php }
         comicpress_pagination();
      } else {
         comicpress_dual_columns();
      }
   } else {
      if (comicpress_themeinfo('blogposts_with_comic')) {
         
         $temppost = $post;
         $temp_query = $wp_query;      
         
         if (comicpress_in_comic_category()) {
            function filter_where($where = '') {
               global $cur_date, $next_date;
               if (!empty($next_date)) {
                  $where .= " AND post_date >= '".$cur_date."' AND post_date <= '".$next_date."'";
               } else {
                  $where .= " AND post_date >= '".$cur_date."'";
               }
               return $where;
            }
            add_filter('posts_where', 'filter_where');
            $posts = &query_posts($blog_query);
            if (have_posts()) { while (have_posts()) : the_post();
                  comicpress_display_post();
                  comments_template('', true);
            endwhile; }
         }
         $post = $temppost; $wp_query = $temp_query; $temppost = null; $temp_query = null;
      }
   }
else:

?>
   <div <?php post_class(); ?>>
      <div class="post-head"></div>
      <div class="post">
         <p><?php _e('Sorry, no posts matched your criteria.','comicpress'); ?></p>
         <div class="clear"></div>
      </div>
      <div class="post-foot"></div>
   </div>
   <?php

endif;
       wp_reset_query();
detach_s2member_query_filters();
   
if (is_active_sidebar('under-blog')) get_sidebar('underblog');

get_footer();
?>


And my index.php

Code:
<?php
get_header();
attach_s2member_query_filters();
if (!comicpress_themeinfo('disable_comic_frontpage') && !comicpress_themeinfo('disable_comic_blog_frontpage') && !is_paged() )  {
   $wp_query->in_the_loop = true; $comicFrontpage = new WP_Query(); $comicFrontpage->query('showposts=1&cat='.comicpress_all_comic_categories_string());
   while ($comicFrontpage->have_posts()) : $comicFrontpage->the_post();
      comicpress_display_post();
   endwhile;
   wp_reset_query();
detach_s2member_query_filters();
}

if (is_active_sidebar('blog')) get_sidebar('blog');

if (!comicpress_themeinfo('disable_blogheader')) { ?>
   <div id="blogheader"><?php echo comicpress_themeinfo('blogheader_text'); ?></div>
<?php
}

if (!comicpress_themeinfo('disable_blog_frontpage')) {
   Protect();
   if (!comicpress_themeinfo('split_column_in_two')) {
      $paged = get_query_var('paged');
      $blog_query = 'showposts='.comicpress_themeinfo('blog_postcount') .'&cat='.comicpress_exclude_comic_categories().'&paged='.$paged;
      $posts = &query_posts($blog_query);
      if (have_posts()) { ?>
         <div class="blogindex-head"></div>
         <div class="blogindex">
         <?php while (have_posts()) : the_post();
            comicpress_display_post();
         endwhile; ?>
         </div>
         <div class="blogindex-foot"></div>
      <?php }
      comicpress_pagination();
   } else {
      comicpress_dual_columns();
   }
   UnProtect();
}

if (is_active_sidebar('under-blog')) get_sidebar('underblog');

get_footer();
?>


If you have some suggestion...

Statistics: Posted by camillemm — September 8th, 2010, 2:16 am


]]>
2010-09-08T01:29:44-05:00 http://www.primothemes.com/forums/viewtopic.php?t=691&p=3049#p3049 <![CDATA[Re: Hiding protected posts]]> because I want to hide the protect post in home and single view but show their existence in all the other views.

Statistics: Posted by camillemm — September 8th, 2010, 1:29 am


]]>
2010-09-08T01:11:35-05:00 http://www.primothemes.com/forums/viewtopic.php?t=691&p=3048#p3048 <![CDATA[Re: Hiding protected posts]]>
As the Alternative protection hide everything, I'm not interested. The purpose is to show something (here a very little thumbnail) in RSS and Tags to say to people it's worth to pay :-) and that they miss something if they don't pay. But it seems I speak to fast. I will have a look to this Alternative protection.

Statistics: Posted by camillemm — September 8th, 2010, 1:11 am


]]>
2010-09-08T00:12:53-05:00 http://www.primothemes.com/forums/viewtopic.php?t=691&p=3041#p3041 <![CDATA[Re: Hiding protected posts]]> Hi there. Thanks for the great question.
I recently did a ComicPress installation for a client. It's a very nice theme design.

It sounds to me like you should go with Tag Level Access, instead of Category Level Access.
In other words, if you protect an entire Category, you're blocking the archive view that is provided by ComicPress. Instead, I would apply s2Member's protection to a special Tag, like: members only or something similar. Then apply that Tag to the Posts that you'd like to block access to. This will allow excerpts of each Post to be visible in archive views, but the Permalinks will still be protected.

In the latest release of s2Member, there is a new form of protection called
"Alternative View Protection". You may also want to look over that section.
In your Dashboard, see: s2 -> General Options -> Alternative View Protection.

Other related topics:
viewtopic.php?f=4&t=640&p=2719&hilit=permalink#p2719
viewtopic.php?f=4&t=587&p=2615&hilit=alternative+view+protection#p2615

Statistics: Posted by Jason Caldwell — September 8th, 2010, 12:12 am


]]>
2010-09-07T11:23:06-05:00 http://www.primothemes.com/forums/viewtopic.php?t=691&p=2963#p2963 <![CDATA[Re: Hiding protected posts]]> Statistics: Posted by camillemm — September 7th, 2010, 11:23 am


]]>
2010-09-07T10:42:16-05:00 http://www.primothemes.com/forums/viewtopic.php?t=691&p=2959#p2959 <![CDATA[Re: Hiding protected posts]]>
Check out the Advanced Query Conditionals.
Dashboard -> API /Scripting -> Advanced Query Conditionals
Advanced Query Conditionals ( some PHP scripting required )

s2Member provides several built-in API Functions that are tailored to meet the needs of developers integrating s2Member into their themes. Such as: is_protected_by_s2member($id, "[category,tag,post,page,singular,uri]"), is_permitted_by_s2member($id, "[category,tag,post,page,singular,uri]"), is_category_protected_by_s2member($cat_id), is_category_permitted_by_s2member($cat_id), is_tag_protected_by_s2member($tag_id [slug or tag name]), is_tag_permitted_by_s2member($tag_id [slug or tag name]), is_post_protected_by_s2member($post_id), is_post_permitted_by_s2member($post_id), is_page_protected_by_s2member($page_id), is_page_permitted_by_s2member($page_id), is_uri_protected_by_s2member($uri [or full url]), is_uri_permitted_by_s2member($uri [ or full url]).

In addition, there are two special functions that can be applied by theme authors before making custom queries: attach_s2member_query_filters(), detach_s2member_query_filters(). These can be used before and after a call to query_posts() for example. s2Member will automatically filter all protected content ( not available to the current User/Member ).

Code:
Example #1: Pre-filtering custom queries in WordPress®.

<?php
attach_s2member_query_filters();
    query_posts("posts_per_page=5");

    if (have_posts()):
        while (have_posts()):
            the_post();
        /*
        Protected content will be excluded automatically.
        ( based on the current User/Member status )
        */
        endwhile;
    endif;

    wp_reset_query();
detach_s2member_query_filters();
?>

Example #2: OR, instead of pre-filtering; check Access Restrictions in The Loop.

<?php
detach_s2member_query_filters();
    query_posts("posts_per_page=5");

    if (have_posts()):
        while (have_posts()):
            the_post();

            if(!is_permitted_by_s2member())
                continue;
            /* Skip it. The current User/Member has NO access. */

        endwhile;
    endif;

    wp_reset_query();
?>

Statistics: Posted by Elizabeth — September 7th, 2010, 10:42 am


]]>
2010-09-07T05:24:11-05:00 http://www.primothemes.com/forums/viewtopic.php?t=691&p=2953#p2953 <![CDATA[Hiding protected posts]]> I use the Comicpress theme for my blog and want to protect one specific category. That's OK :-)
The problem: when a post belongs to the protected category, the visitor is directly moved to the Membershtip Sign Up page. It's the normal behaviour but as my protected posts will be "mixed" with the regular posts, the navigation (it's a "comics" navigation: go to next post, go to previous post) will be very hard for the non registered users.
I want to hide the protected posts to non registered users and that the post shows for the registered. I tried to put "private" for the protected posts (and put a function to show the "private posts" to registered users) but I get some little problems (I wanted to show the count of the post in the protected category and private posts cannot be count).
So I will try some plugin like http://multinc.com/social-privacy/ but I'm afraid they could be interfer with S2member.
If somebody has an idea for my problem, I will be glad to read it :-)

Statistics: Posted by camillemm — September 7th, 2010, 5:24 am


]]>