PriMoThemes — now s2Member® (official notice)

This is now a very OLD forum system. It's in READ-ONLY mode.
All community interaction now occurs at WP Sharks™. See: new forums @ WP Sharks™

Permissions when pulling listings from site

s2Member Plugin. A Membership plugin for WordPress®.

Permissions when pulling listings from site

Postby johnmont » August 7th, 2010, 10:45 am

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);
User avatar
johnmont
Registered User
Registered User
 
Posts: 10
Joined: May 15, 2010

Re: Permissions when pulling listings from site

Postby johnmont » August 17th, 2010, 10:23 am

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?
User avatar
johnmont
Registered User
Registered User
 
Posts: 10
Joined: May 15, 2010

Re: Permissions when pulling listings from site

Postby Jason Caldwell » August 17th, 2010, 3:01 pm

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.
~ Jason Caldwell / Lead Developer
& Zeitgeist Movie Advocate: http://www.zeitgeistmovie.com/

Is the s2Member plugin working for you? Please rate s2Member at WordPress.org.
You'll need a WordPress.org account ( comes in handy ). Then rate s2Member here Image
.
User avatar
Jason Caldwell
Lead Developer
Lead Developer
 
Posts: 4045
Joined: May 3, 2010
Location: Georgia / USA

Re: Permissions when pulling listings from site

Postby johnmont » August 18th, 2010, 12:31 pm

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.
User avatar
johnmont
Registered User
Registered User
 
Posts: 10
Joined: May 15, 2010

Re: Permissions when pulling listings from site

Postby Jason Caldwell » August 27th, 2010, 11:33 am

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 21 times

( check the Changelog for details on this new functionality )
( inside /s2member/readme.txt )
~ Jason Caldwell / Lead Developer
& Zeitgeist Movie Advocate: http://www.zeitgeistmovie.com/

Is the s2Member plugin working for you? Please rate s2Member at WordPress.org.
You'll need a WordPress.org account ( comes in handy ). Then rate s2Member here Image
.
User avatar
Jason Caldwell
Lead Developer
Lead Developer
 
Posts: 4045
Joined: May 3, 2010
Location: Georgia / USA


Return to s2Member Plugin

Who is online

Users browsing this forum: Google [Bot] and 13 guests

cron