API for checking membership level

How can I programmatically check the user membership level with Protected Content.

We are building a very customized service on Wordpress and would like to programmatically check the signed in user membership level in order to enable/disable functionality.


  • Corey Quick
    • Design Lord, Child of Thor

    Hey @Dev, Hope you are having a great day! :slight_smile:

    Once you create memberships via the Protected Content Plugin, you can than enable and disable functionality, pages, etc. via the protected content tab.

    -Let me know if you would like me to set some restrictions for you, or give you a little more direct instruction! :slight_smile:


  • Dev
    • WPMU DEV Initiate

    Hi Corey,

    Thanks for your answer, however my question is different.

    I have already setup Protected Content functionality to standard WP objects, however we are adding custom code in which I need to programmatically (via PHP) check the user's membership level and provide different functionality of our custom code accordingly.

    Is there any kind of a PHP function I can call to check the membership level?
    $level = protectedcontent_ getMembershipLevel($user_ID);
    if ($level == 'silver') {
    // do something

  • Hoang Ngo
    • Code Slayer

    Hi @Dev,

    I hope you are well today.

    You can get the memberships of an user by this way

    $member = MS_Model_Member::get_current_member();
    foreach ( $member->ms_relationships as $subscription ) {
        $membership = $subscription->get_membership();

    The $membership will be an instance of the class MS_Model_Membership, for more information, please check the file /protected-content/app/model/class-ms-model-membership.php

    If you have any issues please don't hesitate to let us know so we can assist

    Best regards,

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.