1. Home
  2. Knowledge Base
  3. OptimizeMember
  4. Scripting – custom capabilities / packages [OptimizeMember]

Scripting – custom capabilities / packages [OptimizeMember]


Packaging Together Custom Capabilities w/ Membership

Using one of OptimizeMember’s Payment Button and/or Form Generators, you can add Custom Capabilities in comma-delimited format. OptimizeMember builds upon existing functionality offered by WordPress Roles/Capabilities. OptimizeMember supports Free Subscribers (at Level #0 ), and several Primary Roles created by the OptimizeMember plugin (i.e. OptimizeMember Levels 1-4, or up to the number of configured Levels ). Each OptimizeMember Level (aka: OptimizeMember Role) provides the Capability current_user_can(“access_optimizemember_level0”), 1, 2, 3, 4, where access_optimizemember_level[0-4] is the Capability associated with each Role; and Membership Levels provide incremental access (i.e. Level #4 Members can also access content at Levels 0, 1, 2, and 3 beneath them).

In short, these Level-based permissions are the default Capabilities that come with each Membership Level being sold on your site. Now, if you’d like to package together some variations of each Membership Level that you’re selling, you can! All you do is add Custom Capabilities whenever you create your Payment Button and/or Form Shortcode (there is a field in the Button & Form Generators where you can enter Custom Capabilities). You can sell Membership Packages that come with Custom Capabilities, and even with custom prices.

Custom Capabilities are an extension to a feature that already exists in WordPress. The current_user_can() function, can be used to test for these additional Capabilities that you allow. Whenever a Member completes the checkout process, after having purchased a Membership from you (one that included Custom Capabilities), OptimizeMember will add those Custom Capabilities to the account for that specific Member.

Custom Capabilities are always prepended with access_optimizemember_ccap_. You fill in the last part, with ONLY lowercase alpha-numerics and/or underscores. For example, let’s say you want to sell Membership Level #1, as is. But, you also want to sell a slight variation of Membership Level #1, that includes the ability to access the Music & Video sections of your site. So, instead of selling this additional access under a whole new Membership Level, you could just sell a modified version of Membership Level #1. Add the Custom Capabilities: music, videos. Once a Member has these Capabilities, you can test for these Capabilities using current_user_can(“access_optimizemember_ccap_music”) and current_user_can(“access_optimizemember_ccap_videos”).

The important thing to realize, is that Custom Capabilities, are just that. They’re custom. OptimizeMember only deals with the default Capabilities that it uses. If you start using Custom Capabilities, you MUST use Simple or Advanced Conditionals (i.e. current_user_can() logic ) to test for them. Either in your theme files with PHP, or in Posts/Pages using Simple Conditionals (powered by Shortcodes).

*New* In the latest versions of OptimizeMember, you can automatically require certain Custom Capabilities on a per Post/Page basis. So now, OptimizeMember (if you prefer) CAN handle Custom Capabilities for you automatically! Whenever you edit a Post/Page (i.e. there is a Meta Box for OptimizeMember in your Post/Page editing station) you can tell OptimizeMember to require certain Custom Capabilities that you type in, using comma-delimited format. In other words, you will need to type in some of the trigger words that you used whenever you created your Payment Buttons/Forms. This way paying Members will have the Custom Capabilities to view different kinds of content that you offer.

*New* By default, a Checkout Button or Form generated by OptimizeMember is designed to (Add) Custom Capabilities to any that may or may not already exist for a particular User/Member. However, starting with OptimizeMember v110815+, you can tell OptimizeMember to (Remove All) Custom Capabilities, and then (Add) only the new ones that you specify. This is accomplished on a per Form/Button basis by preceding your comma-delimited list of Custom Capabilities with `-all`. For further details on this topic, click the [?] icon next to the Custom Capabilities field in any Button/Form Generator supplied by OptimizeMember.

*New* Independent Custom Capabilities. You can now sell one or more Custom Capabilities using Buy Now functionality, to “existing” Users/Members, regardless of which Membership Level they have on your site (i.e. you could even sell Independent Custom Capabilities to Users at Membership Level #0, normally referred to as Free Subscribers, if you like). So, this is quite flexible. For further details, please check your Dashboard, under: OptimizeMember -> PayPal Buttons -> Capability (Buy Now) Buttons.

Custom Capabilities: (music, videos)

<?php if (current_user_can("access_optimizemember_level1")){ ?>
    Some premium content for all Level 1 Members.
    <?php if (current_user_can("access_optimizemember_ccap_music")){ ?>
        Display links for music as well.
    <?php } ?>
    <?php if (current_user_can("access_optimizemember_ccap_videos")){ ?>
        Display videos as well.
    <?php } ?>
<?php } else { ?>
    Some public content.
<?php } ?><br>

Shortcode Version

[opmIf current_user_can(access_optimizemember_level1)] Some premium content for all Level 1 Members. [_opmIf current_user_can(access_optimizemember_ccap_music)] Display links for music as well. [/_opmIf] [_opmIf current_user_can(access_optimizemember_ccap_videos)] Display videos as well. [/_opmIf] [/opmIf]

[opmIf !current_user_can(access_optimizemember_level1)] Some public content. [/opmIf]

Custom Capabilities: (ebooks, reports, tips)

<?php if (current_user_can("access_optimizemember_level1")){ ?>
    Some premium content for all Level 1 Members.
    <?php if (current_user_can("access_optimizemember_ccap_ebooks")){ ?>
        Display links for downloading your eBooks.
    <?php } else { ?>
        Insert a PayPal Modification Button that includes the Custom Capability: ebooks
        This might read, "Upgrade Your Membership for access to my eBooks!".
    <? } ?>
    <?php if (current_user_can("access_optimizemember_ccap_reports")){ ?>
        Display links for accessing your reports.
    <?php } else { ?>
        Insert a PayPal Modification Button that includes the Custom Capability: reports
        This might read, "Upgrade Your Membership for access to my reports!".
    <? } ?>
    <?php if (current_user_can("access_optimizemember_ccap_tips")){ ?>
        Display tips.
    <?php } else { ?>
        Insert a PayPal Modification Button that includes the Custom Capability: tips
        This might read, "Upgrade Your Membership for access to my tips!".
    <? } ?>
<?php } else { ?>
    Some public content.
<?php } ?>

Shortcode Version

[opmIf current_user_can(access_optimizemember_level1)]

Some premium content for all Level 1 Members.

[_opmIf current_user_can(access_optimizemember_ccap_ebooks)] Display links for downloading your eBooks. [/_opmIf] [_opmIf !current_user_can(access_optimizemember_ccap_ebooks)] Insert a PayPal Modification Button that includes the Custom Capability: ebooks This might read, “Upgrade Your Membership for access to my eBooks!”. [/_opmIf]

[_opmIf current_user_can(access_optimizemember_ccap_reports)] Display links for accessing your reports. [/_opmIf] [_opmIf !current_user_can(access_optimizemember_ccap_reports)] Insert a PayPal Modification Button that includes the Custom Capability: reports This might read, “Upgrade Your Membership for access to my reports!”. [/_opmIf]

[_opmIf current_user_can(access_optimizemember_ccap_tips)] Display tips. [/_opmIf] [_opmIf !current_user_can(access_optimizemember_ccap_tips)] Insert a PayPal Modification Button that includes the Custom Capability: tips This might read, “Upgrade Your Membership for access to my tips!”. [/_opmIf]

[/opmIf]

[opmIf !current_user_can(access_optimizemember_level1)] Some public content. [/opmIf]

Was this article helpful?

Related Articles

Need Support?
Can't find the answer you're looking for? Don't worry we're here to help!
Contact Support