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.

Control Content Access by member level

Home Forums Community Forum Control Content Access by member level

This topic contains 4 replies, has 2 voices. Last updated by  Eduan 4 years, 1 month ago.

Topic Author Topic
Posted: Tuesday Dec 4th, 2012 at 1:59 pm #33455

I need to control access to content using the following logic:

If user is a member of group 12 then show this content
[enter content here]

If user is logged in and not a member of group 12 then show this content
[enter different content here]

I am having trouble getting this to work with the shortcodes. Here is what I have:

[s2If !is_user_logged_in()]
<h3>You Do Not have access to this content!</h3>
<h4>Please go to the Membership Options page to join or learn more about what is included with our services.</h4>
[/s2If]

[s2If current_user_is(s2member_level12)]
Content is here
[/s2If]

[s2If is_user_logged_in() AND current_user_cannot(access_s2member_level12)]
Content is here
[/s2If]

Works fine if you are a member of group 12. If you are a member, but not in group 12, you cannot see any content.

  • This topic was modified 4 years, 1 month ago by  Eduan. Reason: Fixed shortcodes

List Of Topic Replies

Viewing 4 replies - 1 through 4 (of 4 total)
Author Replies
Author Replies
Posted: Tuesday Dec 4th, 2012 at 2:31 pm #33460
Eduan
Username: Eduan
Moderator

Hello Tyler,

I don’t understand what you want to achieve. Although, if you’re talking about groups, then I really suggest you use custom capabilities (ccaps for short) instead of levels. Otherwise you will need a whole lot of extra conditional work.

– Eduan

Posted: Tuesday Dec 4th, 2012 at 3:02 pm #33463

Eduan,

I want to show a video to all members unless they are in group 12. The members in group 12 see a custom video branded especially for them.

The logic should work like this:

If the user is a member of group 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11 then show video-1
elseif user is a member of group 12 then show video-2
eleseif if the user is not a member of any group then show the how to become a member page
endif

Can I do this by nesting a statement that says if the user is logged in and not a member of group 12 then show video-1

then if the user is in group 12 then show video-2

otherwise, show the how to become a member page?

Posted: Tuesday Dec 4th, 2012 at 3:58 pm #33466

This worked:

[s2If !is_user_logged_in()]
<h3>You Do Not have access to this content!</h3>
<h4>Please go to the Membership Options page to join or learn more about what is included with our services.</h4>
[/s2If]

[s2If current_user_is(s2member_level1) OR current_user_is_for_blog(24,s2member_level2) OR current_user_is_for_blog(24,s2member_level3) OR current_user_is_for_blog(24,s2member_level4) OR current_user_is_for_blog(24,s2member_level5) OR current_user_is_for_blog(24,s2member_level6) OR current_user_is_for_blog(24,s2member_level7) OR current_user_is_for_blog(24,s2member_level8) OR current_user_is_for_blog(24,s2member_level9) OR current_user_is_for_blog(24,s2member_level10) OR current_user_is_for_blog(24,s2member_level11) ]

CONTENT HERE

[/s2If]
[s2If current_user_is(s2member_level12)]

CONTENT HERE

[/s2If]
  • This reply was modified 4 years, 1 month ago by  Eduan. Reason: Fixed shortcodes
Posted: Tuesday Dec 4th, 2012 at 4:59 pm #33479
Eduan
Username: Eduan
Moderator

I’m glad you found a working solution! :)

Viewing 4 replies - 1 through 4 (of 4 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.