Restricted content not visible to admin

Hi, I’m using shortcodes to curate what is displayed in a particular section of content. (of course :slight_smile: )

[s2If current_user_is(s2member_level4)] level 4 content [/s2If]
[s2If current_user_is(s2member_level3)] level 3 content [/s2If]
[s2If current_user_is(s2member_level2)] level 2 content [/s2If]
[s2If current_user_is(s2member_level1)] level 1 content [/s2If]

[s2If current_user_is(s2member_level0)]Consider Upgrading Your Membership to Reveal this offer [/s2If]

[s2If !is_user_logged_in()]Consider Registering as a Supporter to Reveal this offer[/s2If]

The content is viewable to all(0-4) roles except admin. I’ve cleared cache and checked in chrome/firefox

Any thoughts on what the cause may be?

Resolved:
Now specify “has access” rather than “role is”

1 Like

I’m not sure I understand what you meant there. So each section is visible correctly by the user with the corresponding level, correct? That’s good, that’s what you wanted. And what you’re worried about is that the admin can’t see those sections, is that it? That would be the expected behavior: the admin has the Administrator role, and not Subscriber, s2Member Level 1, etc.

Right. The admin would have all the access capabilities of those levels, so he’d be shown the content. Careful with incremental access of levels, though. If you don’t want a higher level to see the section meant for a lower one, you can’t just check if he has access to level 1, for example, you need to also that he doesn’t have access to a higher level. E.g.

[s2If current_user_can(access_s2member_level1) AND current_user_cannot(access_s2member_level2)]

But that would then not show the section to the admin again haha. In my opinion, don’t worry about not seeing it as the admin in the front end, just go to the editor if you want to see the whole thing.

Or use a plugin that lets you switch roles to view the site while testing. https://s2member.com/kb-article/testing-s2member-access-control-with-user-switching/