Restricting Events to Members Only

I have a site where I allow members to create events to share with other members on a calendar. These events should only be visible to other members of the same or higher membership level. I am using Events Manager Pro to manage and create events. Currently I can restrict the calendar page, but non-logged in users can access an events search page that then allows them to see the events I want to restrict viewing of.

I know S2Member doesn’t handle this out of the box. Where do I start to get these events protected?

Thanks!

Events Manager Pro probably uses its own custom post type (CPT) for each event. So you need to ask its developers (or scour the plugin’s code) to find the name under which that CPT is registered, and then add that, preceded by all-, to the Post Access Restrictions in s2Member.

For example, if the CPT is emp-event, you’d add all-emp-event

1 Like

Thank you! This is immensely helpful!

So I found the custom post type is just called events, so in the case above I can add all-event to the post access restrictions and it restricts the viewing of the full post. This doesn’t restrict the event from showing up on an events list. How would I do that?

They’ve also created custom taxonomies for event categories. Am I able to add a custom taxonomy like an event category to the Category Restrictions?

Yes, except this time you do it by the ID number of the taxonomy.[quote=“lwestcott, post:4, topic:1526”]
This doesn’t restrict the event from showing up on an events list. How would I do that?
[/quote]

Since I don’t have this plugin, I can’t be sure how this feature works. But maybe a simple redirect is all you need. If so, you could add something like this to your (child) theme’s functions.php file:

function event_redirects() {
	if ( !is_user_logged_in() && is_page( 'events' ) ) {
		wp_redirect( home_url( '/welcome/' ) );
		exit;
	}
}
add_action( 'template_redirect', 'event_redirects' );

Obviously, you should adapt this to reflect the name of the actual events page and the URL of the page to which you want the user to be redirected.