Motors - Car Dealership & Classified Listings Mobile App for Android & iOS

How to assign course to a particular membership level?

Started by: Ergon Gervalla January 14, 2019 - 18:17

Our website has 3 membership levels: Free, Silver, Gold.

How can I assign some of the courses to be part of the free level, some for the silver level and some for the gold level?

This feature is present on standard wordpress pages, but it's not on course pages.

Can you please activate this feature to course pages too.



  • Author Team
    #9087 Reply



    The theme uses the Paid Membership Pro plugin for the subscription option which, unfortunately, doesn't contain such option by default. You can only set a limit of courses for the membership levels.


    #9103 Reply

    Ergon Gervalla

    Paid membership pro does indeed have this feature and it works with wp pages.

    #9135 Reply


    Oh this is very unfortunate. I was looking everywhere for this so thanks for the answer.

    The ability to lock courses to membership levels is crucial in my case.

    Do you guys plan to implement this in the future? Is there a roadmap for the project?

    #9844 Reply

    Ayman Abdelsalam

    this feature is very important one , please add this feature in next update .. allow us tolock courses to membership levels , and assign sone courses to every level

    #10231 Reply



    Author Team
    #10240 Reply

    Jonathan Scott

    At the moment, we won't be able to make your request but we'll keep it in mind for future development plans for you sure.

    If there's anything else I can do for you, don't hesitate to let me know!


    #10309 Reply

    Alexander Sverdlov

    so many people are asking for it, and you just choose to ignore them? Me included...

    Author Team
    #10354 Reply

    Matthew Gordon

    We will discuss additional features of the theme with our project managers according to the customers' requirements and add new possibilities to the theme in the future updates of the theme. Unfortunately, we couldn't provide any detailed information about future updates


    #10480 Reply

    Marc-Philipp Schneider

    Than I would like to give my vote for it too.

    #10494 Reply

    Sergio Lissone

    I have the solution to this problem below, it was very easy to find the code on the Paid Memberships Pro website. I spent 10 minutes solving the first part of this problem, which. is all that was asked for. I've also spent much longer adding some extra things you might find helpful. It seems that the MasterStudy LMS theme developers don't have enough resources to manage all of their different themes and plugins, and are neglecting simple requests like this. I've noticed many important features and styling and design options missing from the theme after purchasing, whereas other themes developed by bigger teams like Avada let you have a huge amount of control via numerous theme options. It's ok, I'm not judging anymore after thinking about it for a bit, Avada has a lot of money behind it to afford such a big team of developers. However, I suggest that you guys add some obvious features like the one mentioned in this thread, as your advertising made it seem like this was built in (what other purpose does a membership plugin have?).

    Anyway, here is the code to add to your functions.php file. Delete any lines for the custom post types that you don't need membership control over, I've just added them all here for convenience. What this code does is add the "Require Membership" box in the WordPress admin editing page for any custom post type. Then it works just like it does with pages: you check the boxes for each membership level that has access to the particular custom post, and it will automatically block access to that particular post on the website for non-members.



    Add this code to your functions.php in your child theme:

    * Add the PMPro meta box to a Custom Post Type

    function my_add_pmpro_meta_box_to_cpts() {

    /* Duplicate the next single row for each Custom Post Type. All of them are listed here, some obviously will not be necessary for you so delete the rows that you don't need. */

    add_meta_box('pmpro_page_meta', 'Require Membership', 'pmpro_page_meta', 'product', 'side' );
    add_meta_box('pmpro_page_meta', 'Require Membership', 'pmpro_page_meta', 'stm-courses', 'side' );
    add_meta_box('pmpro_page_meta', 'Require Membership', 'pmpro_page_meta', 'stm-lessons', 'side' );
    add_meta_box('pmpro_page_meta', 'Require Membership', 'pmpro_page_meta', 'events', 'side' );
    add_meta_box('pmpro_page_meta', 'Require Membership', 'pmpro_page_meta', 'gallery', 'side' );
    add_meta_box('pmpro_page_meta', 'Require Membership', 'pmpro_page_meta', 'teachers', 'side' );

    /* Less useful post types to add this to are below, I have no idea why you would want to restrict membership for these but here they are anyway: */

    add_meta_box('pmpro_page_meta', 'Require Membership', 'pmpro_page_meta', 'testimonial', 'side' );
    add_meta_box('pmpro_page_meta', 'Require Membership', 'pmpro_page_meta', 'sidebar', 'side' );
    add_meta_box('pmpro_page_meta', 'Require Membership', 'pmpro_page_meta', 'event_participant', 'side' );
    add_meta_box('pmpro_page_meta', 'Require Membership', 'pmpro_page_meta', 'stm-payout', 'side' );
    add_action( 'admin_menu', 'my_add_pmpro_meta_box_to_cpts', 20 );

    In the future, there may be more custom post types you want to add this functionality to. Here is how you get a list of all of the currently installed custom post type names in your website: create a new blank file in your child theme main folder called post-types-full-list.php or just anything unique and paste this code into it:


    * Template Name: Custom Post Types List


    echo '<h1>Below is a list of all of the custom post types and each of their categories or tags etc:</h1>';

    $args = array(
    'public' => true,
    '_builtin' => false,

    $output = 'names'; // names or objects, note names is the default
    $operator = 'and'; // 'and' or 'or'

    $post_types = get_post_types( $args, $output, $operator );
    if ( ! empty( $post_types ) && is_array( $post_types ) ) {
    foreach ( $post_types as $post_type ) {

    echo '<h2>Post Type Name:</h2>

    <p>' . $post_type . '</p>';

    $taxonomies = get_object_taxonomies( $post_type );
    if ( ! empty( $taxonomies ) && is_array( $taxonomies ) ) {

    echo '<h3>Taxonomies (category/tag types etc) for the ' . $post_type . ' post type:</h3>';
    echo '<ul>';
    foreach ( $taxonomies as $taxonomy ) {

    echo '<li>' . $taxonomy . '

    // Get the individual category/tag/taxonomy names:
    $terms = get_terms(
    'taxonomy' => $taxonomy,
    'hide_empty' => false,

    // Check if any terms exist for this custom post type:
    if ( ! empty( $terms ) && is_array( $terms ) ) {
    // Run a loop and print them all

    echo '<h4>Specific category/tag etc slugs (unique links) for the ' . $taxonomy . ' taxonomy:</h4>';

    foreach ( $terms as $term ) {

    echo '<li>' . $term->slug . '</li>';

    echo '</li>';
    echo '</ul>';



    Then create a new standard page in WordPress and select the "Custom Post Types List" page template in the sidebar in WordPress. Name the page something unique and publish it. Then visit the page, and you will see a full list of all of the post type names. Just copy and paste the ones you want into the relevant bit of the first block of code above, for example 'product' or 'teachers' etc. It also gives you the taxonomy type names, and the specific taxonomy names too, for the next parts:

    Next: if you want to restrict access to an entire post type for only certain levels of members, rather than setting it manually for each individual post or lesson, etc, here is all the code you need, you can ignore all of the above:

    /* Require membership for an entire custom post type. Just replace 'stm-lessons','event_participant' with the names of each custom post type uyou want to restrict, with each name surrounded by single quotes and separated by commas.

    Also, replace 'your-membership-level-1' and 'your-membership-level-2' with the names of any membership level you want to restrict access to for this custom post type, also with the single quotees and commas.


    function cpt_wrong_member_post_type_redirection() {
    if ( in_array( get_post_type( get_the_ID() ), array('stm-courses','stm-lessons','event_participant')) ) {

    if(!pmpro_hasMembershipLevel(array('your-membership-level-1','your-membership-level-2'))) {




    And finally this line will redirect the visitor to a page of your choice if they don't have access:


    just replace '/membership-account/membership-levels/' with whatever the link to the page is, without the part at the start obviously. The get_bloginfo('url'). part of the code will fill in that start part of the link intelligently no matter where you move your site or what domain you put it under.


    And finally, here is how you can restrict custom post type categories like all courses in a certain category:

     function cpt_wrong_member_taxonomy_redirection() {

    /* here we choose our course categories. One line for teach unique type of custom taxonomy/category/tag kind. The format is:

    $some_very_unique_name_I_made_up_for_this_taxonomy_type = array('my-specific-category-name-such-as-art','my-specific-category-name-such-as-music');


    $member_restricted_course_categories_array = array('my-course-category-1','my-course-category-2');

    /* here, it's the same as above, but we're also looking for particular lesson categories, or anything else like a custom post tag etc. As many of these lines as you need for all of your custom taxonomy types. */
    $member_restricted_lesson_categories_array = array('my-lesson-category-1','my-lesson-category-2');

    /* Below, replace stm_lms_course_taxonomy with the custom category/taxonomy type of your choice. You'll get the correct name from my earlier code box above that lists all of the names. Do the same with stm_lessons_category_taxonomy - you can have as many as you want, just add:

    || has_term( $some_very_unique_name_I_made_up_for_this_taxonomy_type, 'my-custom-taxonomy-type-such-as-lesson-category' )

    ...straight after has_term( $member_restricted_lesson_categories_array, 'stm_lessons_category_taxonomy' )

    So I've already got 2 below, but you can replace them as needed.


    if( has_term( $member_restricted_course_categories_array, 'stm_lms_course_taxonomy' ) || has_term( $member_restricted_lesson_categories_array, 'stm_lessons_category_taxonomy' ) ) {

    if(!pmpro_hasMembershipLevel(array('your-membership-level-1','your-membership-level-2'))) {



    And finally, you will notice that there are actually no lesson categories built into this LMS theme. So we'll add them like this:

     /* Register a custom taxonomy for lessons so they can be hidden by category etc */

    add_action( 'init', 'create_lessons_categories_for_memberships' );

    function create_lessons_categories_for_memberships() {
    'label' => __( 'Lesson Categories' ),
    'public' => true,
    'rewrite' => true,
    'hierarchical' => true,

    Author Team
    #10511 Reply


    Hello Sergio,

    Thank you for the provided information and custom solution. We are always trying to improve the theme features in every update. We are including the new features and improvements gradually.

    The new features regarding the subscription with Paid Membership Pro are in our development roadmap. We are planning to implement more flexible settings to membership levels in our future releases.


You must be logged in to reply to this topic.