Current_user_is shortcode conditional not working

Hello, we are having some problems with getting the “current_user_is” shortcodes working, “current_user_can” shortcodes do work however, so it’s odd that only some of them won’t work for us when we are logged in to the appropriately leveled accounts.

For example, this works:
[s2If current_user_can(access_s2member_level4)]
Some premium content for Level 4 Members.
[/s2If]

However this doesn’t (which is what we need):
[s2If current_user_is(s2member_level4)]
Some premium content for Level 4 Members.
[/s2If]

Any ideas? Thanks

current_user_can() is WordPress core. The Codex says that roles can be passed to it, but the results are unreliable. current_user_is() is s2Member. The current_user_is() function (you’ll find it in /s2member/src/functions/sg-functions-inc.php) runs some conditionals and passes the result to current_user_can(). I suspect there are some issues with the roles.

That said, if you have a Level 5 membership defined, you can get only Level 4 members by using:

[s2If current_user_can(access_s2member_level4) AND !current_user_can(access_s2member_level5)]

If you don’t have a Level 5 membership, then current_user_can(access_s2member_level4) is functionally the same as s2If current_user_is(s2member_level4).

For now we only have up to level 4 levels set. What we’re trying to do is get content to show up for any user that is assigned to various levels (And we are using WP Courseware to interact with it, where each level is assigned to a particular course, not sure if that makes a difference). For example, one of our regular WP pages has conditionals set up like so:

[s2If current_user_is(s2member_level4)]
Some premium content for only Level 4 Members.
[/s2If]

[s2If current_user_is(s2member_level3)]
Some premium content for only Level 3 Members.
[/s2If]

[s2If current_user_is(s2member_level2)]
Some premium content for only Level 2 Members.
[/s2If]

[s2If current_user_is(s2member_level1)]
Some premium content for only Level 1 Members.
[/s2If]

[s2If current_user_is(s2member_level0)]
Some content for Free Subscribers.
[/s2If]

And if someone is assigned to both levels 2 and 3, then they would only see the content from those two conditionals respectively. That make sense?

Yes, but the fact remains that current_user_is() and current_user_can() are in this case functionally equivalent. If current_user_can() works and current_user_is() doesn’t, why not use current_user_can()?

1 Like