Protect Events in Membership

Using The Events Calendar plugin:
https://wordpress.org/plugins/the-events-calendar/

Would like to know how to protect events created via the Events Calendar plugin using Membership 2 Pro plugin. basically looking for how to add Membership access to custom post types like events, i.e. we want members to access some events, but not all.

  • Nithin

    Hello Dave,

    Hope you are doing good today. :slight_smile:

    Membership 2 Pro plugin offers option to protect a post either based on content type, or on content type post items.

    By default the the posts are protected based on content types, under Membership 2 > Protection Rules > Custom Post Types

    However, this will protect/hide all the Events posts created via the plugin. If you are looking to only protect some Events post, you could enable the "Individual Custom Posts" add-on, under Membership 2 > Add-ons.

    Once done, the plugin will allow you to protect individual Event post, under Membership 2 > Protection Rules > Custom Post Types Items.

    I hope this should resolve your query. Please let us know if you have any further query, or if there is anything else I should be looking regarding this. Have a nice day ahead. :slight_smile:

    Best Regards,
    Nithin

  • Dave

    Hi we checked this out and it does work but the option to protect content doesn't show up on the actual event itself. We have to go back into the "Set Up Protection Rules" and individually st it after we add the event, a two step process. That's not ideal for client sites where we may have 100+ individual webmasters of varying skill.

    What is easiest way to add the password protection to the top right of custom post types individually?

    See attached examples...the "Enable Protection" doesn't show up on individual events..
    Any ideas on how to make that happen so we can avoid two step process?

    Question .. With the process described, would the event show up for non-approved users at all?

  • Nithin

    Hello Dave,

    Hope you are doing good today. :slight_smile:

    As mentioned in chat, the above solution would require custom coding, as there isn't any out of the box setting in the plugin to carry this out, other than protecting the pages via the Membership 2 > Protection Rules page. I'm pinging the developer regarding this to advise on how to carry this via custom coding, so that it could help you guys get started.

    Either myself or the developer will keep you posted asap. Have a nice day ahead. :slight_smile:

    Best Regards,
    Nithin

  • Kasia Swiderska

    Hello Dave,

    Can you try this code as MU plugin:

    <?php
    
    add_filter( 'ms_controller_membership_metabox_add_meta_boxes_post_types', 'rit_protect_cpt', 10, 1 );
    
    function rit_protect_cpt( $post_types ) {
    	$post_types[] = 'tribe_events';
    
    	return array_unique( $post_types );
    }

    I tested on my site and it works (I have the add-on for Individual Custom Posts still enabled).

    kind regards,
    Kasia

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.