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.

Custom capabilities – AND vs OR

Home Forums Community Forum Custom capabilities – AND vs OR

This topic contains 2 replies, has 2 voices. Last updated by  Andrew Lock 3 years, 11 months ago.

Topic Author Topic
Posted: Wednesday Jan 16th, 2013 at 8:45 pm #37831
Andrew Lock
Username: dsmusic

Hi guys,

I apologise if this has been answered before – I couldn’t find it anywhere but that doesn’t mean it’s not out there somewhere!

Situation is this – I have pages that need to be restricted using Custom Capabilities (in this case, my CC codes are L1T and L2T). Most of the pages are either one or the other, however there are a few that need to be restricted to someone who has either of these codes, ie L1T OR L2T- my question is this:

If I put both of these codes in the custom capabilities field on the post itself, will that read as an AND code or an OR code? Is there a way to write in the CC codes such that this will happen?

Thanks!!

List Of Topic Replies

Viewing 2 replies - 1 through 2 (of 2 total)
Author Replies
Author Replies
Posted: Thursday Jan 17th, 2013 at 4:21 pm #37934
Staff Member

Thanks for your inquiry. ~ We appreciate your patience :-)

I believe what you’re referring to is s2Member’s Meta Box for Post/Page Restrictions, and the Custom Capabilities field that s2Member provides there for site owners. It’s interpreted as AND (i.e. must satisfy all). s2Member will require a User/Member to have ALL of the Custom Capabilities that you list there. If you want to do an OR check, you will need to use conditional shortcodes or PHP code. See example below.

Using Conditional Shortcodes

Leave the field empty in the s2Member Meta Box for Post/Page Restrictions. Instead, you can do something like this within the Post or Page itself. This is just one example, there are many ways to accomplish this with conditionals. See references below.

[s2If current_user_can(access_s2member_ccap_music) OR current_user_can(access_s2member_ccap_videos)]
	Display content for this User/Member.
[/s2If]

See: Dashboard -› s2Member® -› API / Scripting -› Simple/Shortcode Conditionals
See also: Dashboard -› s2Member® -› API / Scripting -› Advanced PHP Conditionals
See also: Video » s2Member (Advanced Conditionals)
See also: Video » s2Member (Custom Capabilities)

Posted: Thursday Jan 17th, 2013 at 9:34 pm #37990
Andrew Lock
Username: dsmusic

Perfect! Thanks so much for that, just what I was after :)

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