latest stable versions: v120514 (changelog)

s2Member® Conditionals

Sometimes the basic s2Member post meta boxes are not enough to get your protections working the way they should. In this case, the easiest way to protect your content is through Conditionals.

Conditionals are something that allow you to specify which content is for which certain level or custom capability. They are available for both the free version of s2Member, and the Pro version of s2Member.

As a simple example, let's say I have two levels, levels 1 & 2, and sell access to a post through specific post/page access restrictions, and I want to show different content depending of the level of the user. For that you would use the following shortcode conditionals:

[s2If current_user_is(s2member_level2)]
	Content exclusively for members level 2.
[/s2If]
[s2If current_user_is(s2member_level1)]
	Content exclusively for members level 1. Maybe something saying "Upgrade now!".
[/s2If]

Now let's say I had a content that I want to be visible to everybody who can access level 1, for that you would use the following conditionals:

[s2If current_user_can(s2member_level1)]
	Content for anybody who can access level 1, this includes levels 1 to 4.
[/s2If]

So as you can see, you can do many interesting combinations with shortcode conditionals. For more info on them, check under WP Admin -> s2Member -> API / Scripting -> Simple/Shortcode Conditionals.

There are also PHP versions of the conditionals, aimed at developers or advanced site owners with more advanced conditionals. You can find them under WP Admin -> s2Member -> API / Scripting -> Advanced/PHP Conditionals.

About the Author

EduanHello everyone! On the web I'm known as Eduan and sometimes known as Greduan. I'm a freelancer who specializes in s2Member. I love s2Member and I like WordPress. I know a fair amount of PHP, JavaScript (jQuery), CSS, MySQL and of course XHTML. I don't work for s2Member.com, I don't know everything about s2Member, but I do know a lot about it. I'm very active in the forums, I try to help every time I can and/or know the answer. If you need private help or a professional s2Member installation, please contact me via my email: eduan [at] snapsimpletech [dot] com.View all posts by Eduan →

If you are a customer, please use our Customer Support Forums for priority support. We also have Community Forums available to all site owners (no purchase required). You can register here (it's free). For further details, please read our Support Policy.