Search for answers:
Customer Notices: WordPress 4.5 Affects LiveEditor Functionality - See this article WordFence Plugin Affects LiveEditor - See this article

Scripting - Custom Capabilities / Packages

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 addCustom 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 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 ?>

---- 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]

Didn't find an answer to your question? Contact Our Support Team (Submit a ticket)
Was this article helpful?
1 out of 1 found this helpful
Follow

Comments

Other Help Categories:

Get Started Guide

Watch our Ultimate Getting Started guide video

Pre-Sales Questions

Ask questions before purchasing our products

Login Problems

If you're having issues logging into our members hub

Accounts & Billing

Update your billing, request a refund and other accounts help

API Key Issues

Get help with licensing your site and API key issues

Membership Help

Get help creating Membership portals and courses

LiveEditor Help

If you need help using or troubleshooting the LiveEditor

Integrations

Find out about the many integrations possible with OptimizePress

Affiliate Questions

Have questions about promoting OptimizePress

Clubhouse Questions

Questions about our Clubhouse Membership Subscription