Page 1 of 1

conditional tags do not work

PostPosted: April 19th, 2011, 5:52 pm
by buddy101
Hello,

Conditionals with s2If do not seem to work for me for some reason. Here is what I tried -

1. i changed the post access restriction from level0 to blank (using level 0 only for now)
2. added the following after the more tag in html view

Code: Select all
[s2If !current_user_can(access_s2member_level0)]
If you wish to read further, you would need to be a <strong>[s2Get constant="S2MEMBER_LEVEL0_LABEL" /]</strong>. <a href="[s2Get constant="S2MEMBER_LOGIN_PAGE_URL" /]">Login</a> to your account or if you have not registered with us yet, feel free to <a href="[s2Get constant="S2MEMBER_LOGIN_PAGE_URL" /]?action=register">register</a> to gain access to this content.
[/s2If]


[s2If current_user_can(access_s2member_level0)]
Protected content goes here.
[/s2If]


3. When I access the post as a guest, I can see both Protected content and the prompt to register (which would suggest both ifs are succeeding !!). Sometimes I get redirected to membership options page as if there was a post level restriction.

Re: conditional tags do not work

PostPosted: April 19th, 2011, 8:55 pm
by Cristián Lávaque
Hi buddy. :)

That's weird. OK, try using the current_user_cannot function instead then:

Code: Select all
[s2If current_user_cannot(access_s2member_level0)]
...
[/s2If]


I'd also suggest you take a look at the alt. views protection setting. WP Admin -> s2Member -> General Options -> Alternative Views Protection

And watch this video, it may help you with this: http://www.s2member.com/content-restric ... ble-video/

If you still have trouble with this, please post a screenshot of your content protection panels from General Options.

Re: conditional tags do not work

PostPosted: May 3rd, 2011, 10:06 pm
by buddy101
I tried
Code: Select all
current_user_cannot
instead of
Code: Select all
!current_user_can
, it still does not seem to work. Both
Code: Select all
current_user_cannot
and
Code: Select all
current_user_can
seem to be satisfied on the protected content. This may be a bug triggered if the content was at some point protected at post level and now being switched to conditional protection ? I have no idea what is going on.

Re: conditional tags do not work

PostPosted: May 3rd, 2011, 11:43 pm
by Cristián Lávaque
Got it.

Could you post the actual code you tried to protect the content?

And could you please post screenshots of the access restriction panels in your General Options page? WP Admin -> s2Member -> General Options

Re: conditional tags do not work

PostPosted: May 13th, 2011, 10:42 am
by buddy101
I have sent screenshots to Jason, you should be getting them shortly.

Re: conditional tags do not work

PostPosted: May 13th, 2011, 4:21 pm
by Jason Caldwell
Thank you. Investigating now.