Multiple level conditional shortcode s2member

Hi

I have the following shortcode working:

[s2If current_user_can(access_s2member_level1)]

I found this here Help with conditional shortcode for custom profile fields

Would it be possible to add multiple levels to the shortcode above, not just level 1?

Thanks

Matt

Yes you can. In the s2Member installation, under API / Scripting > Simple/Shortcode Conditionals, you can see all kinds of ways you can use shortcodes with various conditionals. You can do this too:
[s2If current_user_is(s2member_level2) OR current_user_is(s2member_level1)]
or
[s2If current_user_is(s2member_level2) AND current_user_is(s2member_level1)]

Depending on what you want. You can add multiple ones too.

Hi Cassel

I tried the below codes, but when i viewed page admin couldn’t see restricted content and, as admin, should be able to see restricted content.

[s2If current_user_is(s2member_level2) OR current_user_is(s2member_level1)]
[s2If current_user_is(s2member_level2) AND current_user_is(s2member_level1)]

Any idea why not working?

Thanks

Matt

no - admin should not see this. You used the wrong code. You need to use current_user_can_access (it’s not correct - check the proper naming - but there is one that means exactly this). Otherwise put an AND current_user_is_(admin) or however that one is written correctly.

Hi Felix

I tried below but admin still can’t see restricted content:

[s2If current_user_is(s2member_level2) AND current_user_is(s2member_level1) AND current_user_is_(admin)]

Matt

of course you can’t - you need to use OR because you are admin and not s2member_level2. AND is not OR

[s2If current_user_is(s2member_level2) OR current_user_is(s2member_level1) OR current_user_is_(admin)]

I tried above but admin still cant see restricted content.

`[s2If current_user_is(s2member_level2) OR current_user_is(s2member_level3)]`

this works, but admin cant see content.

As replied by @openmtbmap you need to use “can” not “is”

[s2If current_user_can(access_s2member_level1)]
    Some content for Members who are logged in with an s2Member Level >= 1.
[/s2If]

See https://s2member.com/kb-article/s2if-simple-shortcode-conditionals/