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™

S2Member - List restricted pages

s2Member Plugin. A Membership plugin for WordPress®.

S2Member - List restricted pages

Postby prema » March 23rd, 2011, 10:43 am

Hi,

I m using S2 member plugin & restricted few pages & posts.
How to display a list of restricted pages & posts in right side bar ?
Thanks in advance

- Prema
User avatar
prema
Registered User
Registered User
 
Posts: 13
Joined: March 16, 2011

Re: S2Member - List restricted pages

Postby Cristián Lávaque » March 23rd, 2011, 9:01 pm

Hi Prema.

You'll need to create a widget with some PHP to show that custom output.

You could update the list with an array containing the IDs of the pages that you protected and then foreach it to create the HTML list in the widget.

If you also want to display in some way if the current user has access to each page or not, you'd need to use some advanced query conditionals too: WP Admin -> s2Member -> API / Scripting -> Advanced Query Conditionals.

Hope that helps. :)
Cristián Lávaque http://s2member.net
Is s2Member working for you? Please rate it Image at WordPress.org. Thanks! :)
User avatar
Cristián Lávaque
Developer
Developer
 
Posts: 6836
Joined: December 22, 2010

Re: S2Member - List restricted pages

Postby prema » March 24th, 2011, 3:51 am

Thanks for reply.
But how to get an array of restricted Post Titles ?
Thanks in advance

- Prema
User avatar
prema
Registered User
Registered User
 
Posts: 13
Joined: March 16, 2011

Re: S2Member - List restricted pages

Postby Cristián Lávaque » March 25th, 2011, 12:11 am

Since you're the one protecting them, you'd know which they are.

If you protected IDs 123,345,456,567 then your array could be

Code: Select all
$my_protected_ids = array(123,345,456,567); 
Cristián Lávaque http://s2member.net
Is s2Member working for you? Please rate it Image at WordPress.org. Thanks! :)
User avatar
Cristián Lávaque
Developer
Developer
 
Posts: 6836
Joined: December 22, 2010

Re: S2Member - List restricted pages

Postby prema » March 25th, 2011, 6:28 am

Thanks Lávaque.

How to get dynamically through code instead of hard coding like

$my_protected_ids = array(123,345,456,567);

?
Thanks in advance

- Prema
User avatar
prema
Registered User
Registered User
 
Posts: 13
Joined: March 16, 2011

Re: S2Member - List restricted pages

Postby Jason Caldwell » March 26th, 2011, 4:09 am

Thanks for the excellent question.
~ and thank you for bringing this to my attention Cristián.


s2Member stores this information in it's array of configured options.
Code: Select all
<?php
$protected_level1_posts_array 
= preg_split ("/[\r\n\t\s;,]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level1_posts"]);
$protected_level1_pages_array = preg_split ("/[\r\n\t\s;,]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level1_pages"]);
$protected_level1_posts_pages_array = array_merge ($protected_level1_posts_array, $protected_level1_pages_array);

$my_protected_ids = $protected_level1_posts_pages_array;
?>
* Of course, you may need to alter this code ( or add to it )
if you have protected Posts/Pages at many different Membership Levels.
~ 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: S2Member - List restricted pages

Postby prema » March 26th, 2011, 7:03 am

Thats Great!!

One more doubt.

Can we get these restricted IDs after a s2Member login ?

Coz, Before logging in its working fine, didnt give any output after login.


!!!!
Thanks in advance

- Prema
User avatar
prema
Registered User
Registered User
 
Posts: 13
Joined: March 16, 2011

Re: S2Member - List restricted pages

Postby Jason Caldwell » March 26th, 2011, 9:36 pm

You're very welcome. Thanks for the follow-up.
prema wrote:Thats Great!!
One more doubt.
Can we get these restricted IDs after a s2Member login ?
Coz, Before logging in its working fine, didnt give any output after login.

These options only change when you modify your s2Member configuration in the s2Member -> General Options panel. If you are seeing differences between being logged-in vs. not logged-in; I suspect the issue is originating from something other than the code sample above. So to answer your question, no. These option values do not change; even when a User/Member is logged-in.
~ 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: No registered users and 2 guests

cron