latest stable versions: v150827 (changelog)

Old Forums (READ-ONLY): The community now lives at WP Sharks™. If you have an s2Member® Pro question, please use our new Support System.

Settings: If Current User Is….

Home Forums Community Forum Settings: If Current User Is….

This topic contains 5 replies, has 3 voices. Last updated by  Buck 3 years, 7 months ago.

Topic Author Topic
Posted: Saturday Jun 1st, 2013 at 5:41 pm #51148
Buck
Username: stephenbuck415

I notice that when I add this code:

[s2If current_user_is(s2member_level1)]
Some text
[/s2If]

And then view the page through my Administrator account, I am unable to see the text for Level 1.

Is the code supposed to do that, or have I missed a setting somewhere that would enable Admin to see its restricted content?

List Of Topic Replies

Viewing 5 replies - 1 through 5 (of 5 total)
Author Replies
Author Replies
Posted: Sunday Jun 2nd, 2013 at 3:08 am #51164

Yes, it’s suppossed to do that, because you’re not asking if the user has access to Level 1 content, you’re asking if he’s at Level 1, which an Administrator isn’t. Try:

[[s2If current_user_is(s2member_level1) OR current_user_is(administrator)]
Some text
[/s2If]]

or

[[s2If current_user_can(access_s2member_level1)]
Some text
[/s2If]]

The latter will be shown to Level 2 users or higher too, though, because of the incremental access.

Posted: Sunday Jun 2nd, 2013 at 9:15 am #51173
Buck
Username: stephenbuck415

Oh, I see.

Thank you.

Posted: Sunday Jun 2nd, 2013 at 10:49 am #51174
Buck
Username: stephenbuck415

I’ve been reading s2Member > API Scripting > Simple / Shortcode Conditionals and want to confirm my understanding.

If I want Levels 1-4 to have access to a restricted block of text or content, and also want myself as administrator to be able to see the content on the page when viewed through my administrator account, then the code I would use is:

[s2If current_user_is(s2member_level1) OR current_user_is(s2member_level2) OR current_user_is(s2member_level3) current_user_is(s2member_level4) OR OR current_user_is(administrator)]
Some text
[/s2If]

Or is there a simpler code to accomplish that?

Posted: Tuesday Jun 4th, 2013 at 4:28 am #51276
Bruce
Username: Bruce
Staff Member

If I want Levels 1-4 to have access to a restricted block of text or content, and also want myself as administrator to be able to see the content on the page when viewed through my administrator account, then the code I would use is:

If you want all membership levels above a certain level (including Admin) to be able to see a certain piece of content, you can use the current_user_can() function. In this case it would look something like this:

[s2If current_user_can(access_s2member_level1)]
Some text
[/s2If]
Posted: Tuesday Jun 4th, 2013 at 5:17 am #51298
Buck
Username: stephenbuck415

Okay thank you.

Viewing 5 replies - 1 through 5 (of 5 total)

This topic is closed to new replies. Topics with no replies for 2 weeks are closed automatically.

Old Forums (READ-ONLY): The community now lives at WP Sharks™. If you have an s2Member® Pro question, please use our new Support System.

Contacting s2Member: Please use our Support Center for bug reports, pre-sale questions & technical assistance.