I've set up a number of subscription packages on my WP/Buddypress install which allow/restrict the type of content members can create/upload using custom capabilities (Blog creation package, Media upload package, Group creation package).
My subscription plan structure looks like this:
Lev 1 plans - Blogs package only, Media package only or Groups package only
Lev 2 plans - Blogs & Media, Blogs & Groups, Media & Groups
Lev 3 plan - Blogs, Media & Groups
For subscription modification/upgrades, I want to code the membership options page so that the current plan to which the member is subscribed is identified according to packages included in the plan, and display only modification buttons for those packages NOT included.
For Level 1 (single) plans, it's pretty straightforward... the code is right there in the documentation:
- Code: Select all
<?php if (is_user_logged_in() && current_user_can("access_s2member_level1")){ ?>
<?php if (current_user_can("access_s2member_ccap_blogs")){ ?>
Show subscription modification buttons to add Media OR Group packages
<?php } ?>
<?php if (current_user_can("access_s2member_ccap_media")){ ?>
Show subscription modification buttons to add Blogs OR Group packages
<?php } ?>
<?php if (current_user_can("access_s2member_ccap_groups")){ ?>
Show subscription modification buttons to add Blogs OR Media packages
<?php } ?>
<?php } ?>
For Level 2 (double) plans, I need to identify which of the 3 packages the member is currently NOT subscribed to. So, what would be the better way to accomplish this?
- Code: Select all
<?php if (is_user_logged_in() && current_user_can("access_s2member_level2")){ ?>
<?php if (!current_user_can("access_s2member_ccap_blogs")){ ?>
Show subscription modification buttons to add Blogs package
<?php } ?>
<?php } ?>
----OR----
- Code: Select all
<?php if (is_user_logged_in() && current_user_can("access_s2member_level2") && !current_user_can("access_s2member_ccap_blogs")){ ?>
Show subscription modification buttons to add Blogs package
<?php } ?>
----OR-----
- Code: Select all
<?php if (is_user_logged_in() && current_user_can("access_s2member_level2") && current_user_can("access_s2member_ccap_media") && current_user_can("access_s2member_ccap_groups")){ ?>
Show subscription modification buttons to add Blogs package
<?php } ?>
...etc...
So, there seem to be actually several ways I could do this. Which would be better?