Page 1 of 1

Permissions when pulling listings from site

PostPosted: August 7th, 2010, 10:45 am
by johnmont
Diving back into some customization for my WordPress using MemberPro and hitting a wall. I understand how the conditionals and constants can be used to restrict access to displaying certain pages, etc. But I'm running into an issue when trying to figure out how to restrcit listings of protected items. I've read many of the posts here as well as the docs, but I appear to be missing something.

One aspect of my site is creating an XML listing for an external application (which would be logged into the site via the login mechanism). This would be a list of ids that the application can then build a menu for showing what is available. An example URL the app requests would be:

http://site.com/getListing?catids=13,15,16

The problem is that I don't see a way to determine if a particular post or category is restricted. I've included my php code below, with <<<<----- signifying where I want to do a check.

Any suggestions...and sorry if this is plainly covered somewhere.

Code: Select all
foreach( $catids as $catID ) {
   
   if (MEMBER CANNNOT ACCESS CATEGORY) continue;   <<<<---- check and skip
   $args = array( 'posts_per_page' => $numposts, 'cat' => $catID, 'post_type' => array( 'post', 'gallery','ad') ); 
   $my_query = new WP_Query($args);
   while ($my_query->have_posts()) : $my_query->the_post();
          if (MEMBER CANNNOT ACCESS POST) continue;   <<<<---- check and skip
          echo  $post->ID;
   endwhile;
}


If I can pass something on to query_args, I can do this as well -- using something like this:
Code: Select all
  $args = array( 'posts_per_page' => $numposts, 'cat' => $catID); 
  $my_query = new WP_Query($args);

Re: Permissions when pulling listings from site

PostPosted: August 17th, 2010, 10:23 am
by johnmont
Just bumping this, as it's a pretty big aspect of what I'm trying to do on my site with the Pro plugin. I'd like to have some checks on permissions to access a category, etc....

if (MEMBER CANNNOT ACCESS CATEGORY) continue; <<<<---- check and skip
if (MEMBER CANNNOT ACCESS POST) continue; <<<<---- check and skip

Is this possible outside the loop?

Re: Permissions when pulling listings from site

PostPosted: August 17th, 2010, 3:01 pm
by Jason Caldwell
Hi John. I'm very sorry for my extremely delayed response to this question.

Thanks for the great suggestion.

No, this is NOT possible yet, at least not without custom coding.
However, I'm pushing this up to the tippy top of our TODO list.

@C/TODO :: add API functions:
s2member_is_category_protected([ cat ID ])
s2member_is_single_protected([ post ID])
s2member_is_uri_protected([ URI ])
etc, etc.
or some variation of these concepts.


You can expect to see this feature added in the very next release.
In the mean time, I would suggest that you have a look at these files:

Code: Select all
/includes/functions/catg-level-access.inc.php
/includes/functions/post-level-access.inc.php

Using the same logic as you'll see in those files,
you could build a custom function that would behave the way you need.

Re: Permissions when pulling listings from site

PostPosted: August 18th, 2010, 12:31 pm
by johnmont
Jason Caldwell wrote:Hi John. I'm very sorry for my extremely delayed response to this question.


No worries about the delay, I've been slammed myself. :)

I think I'll wait it out for the next release since I've got some other things to do (like testing PayPal Pro). Knowing that you're adding this is awesome, because I think it will really help expand the functionality of the the plugin.

Re: Permissions when pulling listings from site

PostPosted: August 27th, 2010, 11:33 am
by Jason Caldwell
Hi John. This has been implemented in s2Member v3.2.3 ( to be released soon ).
@COMPLETED/TODO :: add API functions.

~ Here is a beta release if you'd like to start early.
s2member-3.2.3-beta-1.zip
(5.43 MiB) Downloaded 22 times

( check the Changelog for details on this new functionality )
( inside /s2member/readme.txt )