latest stable versions: v150311 (changelog)

s2Member® Conditionals

There is a more up-to-date version of this article, created by Jason:

s2Member® Simple Shortcode 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 current_user_is(s2member_level1)]
	Content exclusively for members level 1. Maybe something saying "Upgrade now!".

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(access_s2member_level1)]
	Content for anybody who can access level 1, this includes levels 1 to 4.

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

EduanI already wrote a good description about myself in my website: all posts by Eduan →

Contacting s2Member: Please use our Support Center for bug reports, pre-sale questions & technical assistance.