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.

allow more customcapabilities in if statement

Home Forums Community Forum allow more customcapabilities in if statement

This topic contains 3 replies, has 2 voices. Last updated by  cassel 4 years, 3 months ago.

Topic Author Topic
Posted: Monday Sep 24th, 2012 at 8:02 am #26292
LetUsLook
Username: lucjager

Dear S2member,

is it possible to have more than one custom capability in the if statement?

Example (current situation)

<?php if (current_user_can("access_s2member_ccap_videos")){ ?>
    Display videos as well.
<?php } ?>

How i want it (acces with ccap videos and ccap music)

<?php if (current_user_can("access_s2member_ccap_videos&music")){ ?>
     Display videos as well.
 <?php } ?>

List Of Topic Replies

Viewing 3 replies - 1 through 3 (of 3 total)
Author Replies
Author Replies
Posted: Monday Sep 24th, 2012 at 8:30 am #26298
cassel
Username: cassel

Yes you can. You can do it with shortcodes:
[s2If current_user_can(access_s2member_ccap_video) AND current_user_can(access_s2member_ccap_music)]

or in php:

<?php if (current_user_can("access_s2member_ccap_videos")) && (current_user_can("access_s2member_ccap_music")) { ?>
    Display videos and music as well.
<?php } ?>
Posted: Monday Sep 24th, 2012 at 9:25 am #26302
LetUsLook
Username: lucjager

One more question, what if you access the content if you have one of them or both?

so you can access the content with either, the music or the video ccap or when you have both

  • This reply was modified 4 years, 3 months ago by  LetUsLook.
Posted: Monday Sep 24th, 2012 at 9:38 am #26306
cassel
Username: cassel

The && stands for “and” in which case the member needs both ccaps. If you use the || it will stand for “or” in which case the member needs one OR the other, but is not required to have both to access the protected content with that conditional.

The ccaps and conditionals are extremely powerful and versatile.

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