Page 1 of 1

API: Determine Which Membership Level a Page Is Set To

PostPosted: June 13th, 2011, 5:03 pm
by skinnytires
A site admin sets page/post 123 to Member Level X.

Within my theme templates, how do I programmatically determine what that value is? I see 'is_page_protected_by_s2member()' but I'm in need of something more like: 'page_membership_level() ' so that I can test for MembershipLevel 0 case as well as the NULL case.

I'm setting up some Drip Content logic and wondering how to access that info. Looked through the API but couldn't find an answer.

Code: Select all
// If page's membership level is NULL or level 0, define drip dates by when user became a free member
if ($page_membership_level >= 0) {
  $days_since_member = S2MEMBER_CURRENT_USER_REGISTRATION_DAYS;
 
} else {
  // If page's membership level is >= level 1, define drip dates by when user became a paying member
  $days_since_member = S2MEMBER_CURRENT_USER_PAID_REGISTRATION_DAYS;
}


Loving this plugin so far! Working through it. Very impressed so far. Thank you!

Re: API: Determine Which Membership Level a Page Is Set To

PostPosted: June 14th, 2011, 2:37 am
by Cristián Lávaque
Thanks for the kudos! It's great to know you're liking it. :)

About checking the restriction, why isn't that function enough? Here's the documentation for it viewtopic.php?f=40&t=9015&src_doc_v=110605#src_doc_is_page_protected_by_s2member%28%29

What exactly do you need?

Re: API: Determine Which Membership Level a Page Is Set To

PostPosted: June 14th, 2011, 8:58 am
by skinnytires
Hi Cristian - thanks so much for the reply.

Aarrgh. You are right! Shows I didn't read the full info:

"When/if the Page IS protected, the return array will include one of these keys ["s2member_(level|sp|ccap)_req"] indicating the Level #..."

Thanks much Cristian. I will try this out. Cheers.

Re: API: Determine Which Membership Level a Page Is Set To

PostPosted: June 14th, 2011, 9:48 am
by Cristián Lávaque
Cool. :)