{"id":1896509,"date":"2019-10-18T13:19:18","date_gmt":"2019-10-18T17:19:18","guid":{"rendered":"https:\/\/theeventscalendar.com\/knowledgebase\/making-a-members-only-calendar\/"},"modified":"2026-04-23T18:07:24","modified_gmt":"2026-04-23T22:07:24","slug":"members-only-calendar","status":"publish","type":"post","link":"https:\/\/theeventscalendar.com\/knowledgebase\/members-only-calendar\/","title":{"rendered":"Making a Members-Only Calendar"},"content":{"rendered":"\n\n\n<p>We are sometimes asked if The Events Calendar allows for the creation of &#8220;members-only&#8221; or &#8220;internal&#8221; calendar\u2014a calendar whose events can <em>only<\/em> be seen by logged-in users.<\/p>\n\n\n\n<p><strong>Currently there is no &#8220;out of the box&#8221; way to make this sort of calendar\u2014no plugin setting, plugin filter, etc.<\/strong> But with a bit of custom coding, you can get pretty close.<\/p>\n\n\n\n<p>The methods covered in this article are as follows:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"#using-a-redirect\">Method One: Using a Redirect<\/a><\/li>\n\n\n\n<li><a href=\"#using-css\">Method Two: Using CSS<\/a><\/li>\n\n\n\n<li><a href=\"#using-a-plugin\">Method Three: Using a Third Party Plugin<\/a><\/li>\n<\/ul>\n\n\n\n<p>\u26a0\ufe0f <strong>Please Note:<\/strong> This is not an official feature, so it is not something we can assist with at our help desk. When implementing custom code on your site, please note that you are responsible for maintaining this custom code over time as you update plugins, themes, your site&#8217;s version of WordPress, etc.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-css-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"using-a-redirect\">Method One: Using a Redirect<\/h3>\n\n\n\n<p>This method is a stringent, very literal &#8220;members-only&#8221; calendar. <strong>With this method, there are no events visible to <em>any site visitor who is not logged-in<\/em>.<\/strong> If a visitor has not logged in, and tries to access an event view\u2014whether Month View, List View, Photo View, etc.\u2014they are simply redirected to a page of your choosing.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">The Main Redirect<\/h4>\n\n\n\n<p>The main events page redirect is dictated by adding code like the following to your theme&#8217;s <em>functions.php<\/em> file, or a custom plugin:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: php; title: ; notranslate\" title=\"\">\nadd_filter( &#039;tribe_events_pre_get_posts&#039;, &#039;redirect_from_events&#039; );\nfunction redirect_from_events( $query ) {\n\tif ( is_user_logged_in() )\n\t\treturn;\n\n\tif ( ! $query-&gt;is_main_query() || ! $query-&gt;get( &#039;eventDisplay&#039; ) )\n\t\treturn;\n\n\t\/\/ Look for a page with a slug of &quot;logged-in-users-only&quot;.\n\t$target_page = get_posts( &#x5B;\n\t\t&#039;post_type&#039; =&gt; &#039;page&#039;,\n\t\t&#039;name&#039; =&gt; &#039;logged-in-users-only&#039;\n\t ] );\n\n\t\/\/ Use the target page URL if found, else use the home page URL.\n\tif ( empty( $target_page ) ) {\n\t\t$url = get_home_url();\n\t} else {\n\t\t$target_page = current( $target_page );\n\t\t$url = get_permalink( $target_page-&gt;ID );\n\t}\n\t\n\t\/\/ Redirect!\n\twp_safe_redirect( $url );\n\texit;\n}\n<\/pre><\/div>\n\n\n<p>The above example code &#8220;listens&#8221; for logged-out users attempting to load event pages. It will send them to a page with a slug of <em>\/logged-in-users-only<\/em> if that page exists. So, for example, if your site was <kbd>example.com<\/kbd> and you made a page at <kbd>example.com\/logged-in-users-only<\/kbd>, a logged-out user would be redirected to that page if it exists. If that page does not exist, they will be redirected to the site&#8217;s home page.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">An Additional Precaution<\/h4>\n\n\n\n<p>While the above redirect will prevent any logged-out visitors from viewing an events view like the List View, Month View, etc., you might <em>also<\/em> want to add the following snippet to stop event database queries outright if the current visitor is not logged in. <strong>This will make it so that event widgets are <em>also<\/em> empty<\/strong> if the visitor is not logged in.<\/p>\n\n\n\n<p>The extra snippet of code for this added layer of restriction\u2014which, again, is totally optional!\u2014is as follows:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: php; title: ; notranslate\" title=\"\">\nadd_filter( &#039;posts_where&#039;, &#039;restrict_events&#039;, 100 );\nfunction restrict_events( $where_sql ) {\n\tglobal $wpdb;\n\tif ( is_user_logged_in() || ! class_exists( &#039;Tribe__Events__Main&#039; ) ) {\n\t\treturn $where_sql;\n\t}\n\treturn $wpdb-&gt;prepare( &quot; $where_sql AND $wpdb-&gt;posts.post_type &lt;&gt; %s &quot;, Tribe__Events__Main::POSTTYPE );\n}\n<\/pre><\/div>\n\n\n<h3 class=\"wp-block-heading\" id=\"using-css\">Method Two: Using CSS<\/h3>\n\n\n\n<p><strong>With this secondary method, only <em>certain, specified<\/em> events are hidden from logged-out visitors.<\/strong> The events that are &#8220;internal-only&#8221; or &#8220;members-only&#8221; are categorized as such, and these are the events that logged-out visitors will not see. All other events, though, will remain publicly visible.<\/p>\n\n\n\n<p>This method is fairly simple to implement. First, create an event category that all members-only events will belong to. In the following screenshot, this is exemplified with an event category called &#8220;Members Only&#8221;:<\/p>\n\n\n\n<figure class=\"wp-block-image\"><a href=\"https:\/\/images.theeventscalendar.com\/kb\/uploads\/2014\/09\/Screen-Shot-2016-07-19-at-9.41.18-PM.png\"><img decoding=\"async\" src=\"https:\/\/images.theeventscalendar.com\/kb\/uploads\/2014\/09\/Screen-Shot-2016-07-19-at-9.41.18-PM.png\" alt=\"A Members-Only Category\"\/><\/a><\/figure>\n\n\n\n<p>An example of adding a members-only category to an event.<\/p>\n\n\n\n<p>As expected, that event will show up, as shown in the Month View in the following screenshot:<\/p>\n\n\n\n<figure class=\"wp-block-image\"><a href=\"https:\/\/images.theeventscalendar.com\/kb\/uploads\/2014\/09\/Screen-Shot-2016-07-19-at-9.44.57-PM.png\"><img decoding=\"async\" src=\"https:\/\/images.theeventscalendar.com\/kb\/uploads\/2014\/09\/Screen-Shot-2016-07-19-at-9.44.57-PM.png\" alt=\"Screen Shot 2016-07-19 at 9.44.57 PM\"\/><\/a><\/figure>\n\n\n\n<p>To hide any event in that members-only category, you can do that by adding CSS like the following to the bottom of your theme&#8217;s <em>style.css<\/em> file:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: css; title: ; notranslate\" title=\"\">\n.type-tribe_events.tribe-events-category-members-only {\n  display: none;\n}\n<\/pre><\/div>\n\n\n<p>\u261d\ufe0f That CSS will hide the events in the &#8220;Members Only&#8221; event category, as shown here:<\/p>\n\n\n\n<figure class=\"wp-block-image\"><a href=\"https:\/\/images.theeventscalendar.com\/kb\/uploads\/2014\/09\/Screen-Shot-2016-07-19-at-10.02.42-PM.png\"><img decoding=\"async\" src=\"https:\/\/images.theeventscalendar.com\/kb\/uploads\/2014\/09\/Screen-Shot-2016-07-19-at-10.02.42-PM.png\" alt=\"Screen Shot 2016-07-19 at 10.02.42 PM\"\/><\/a><\/figure>\n\n\n\n<p>Now you just need to add one extra bit of CSS so that the event <em>will<\/em> be visible if you are logged-in. That extra bit of CSS looks like this:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: css; title: ; notranslate\" title=\"\">\nbody.logged-in .type-tribe_events.tribe-events-category-members-only {\n  display: inline;\n}\n<\/pre><\/div>\n\n\n<p>The event will remain hidden from view if you are logged out, but it will show like normal if you are logged in. All other events that are <em>not<\/em> in that &#8220;Members Only&#8221; category will be visible regardless of whether you are logged in or not.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"using-a-plugin\">Method Three: Using a Third-Party Plugin<\/h3>\n\n\n\n<p>Lastly, you can use a third-party plugin to add this feature to your website. Specifically, <a href=\"https:\/\/restrictcontentpro.com\/\" target=\"_blank\" rel=\"noreferrer noopener\">Restrict Content Pro<\/a> can add this functionality to your calendar with The Events Calendar. You can read all about how to integrate with Restrict Content Pro in <a href=\"https:\/\/theeventscalendar.com\/knowledgebase\/k\/integrating-restrict-content-pro-with-the-events-calendar\/\" target=\"_blank\" rel=\"noreferrer noopener\">our Knowledgebase article<\/a>.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Closing Thoughts and Tips<\/h3>\n\n\n\n<p>With the above methods, a bit of time, and a bit of tinkering, you should be able to implement a members-only calendar on your site. Since code customization is required, and we will thus <strong><a href=\"https:\/\/theeventscalendar.com\/knowledgebase\/k\/what-support-is-provided-for-license-holders\/\" target=\"_blank\" rel=\"noreferrer noopener\" aria-label=\" (opens in a new tab)\">not be able to help with implementing these customizations at our help desk<\/a><\/strong>, here are some resources that may be helpful when implementing a members-only calendar:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>If you want to learn more about the PHP involved in writing functions like those seen in Method One, check out <a href=\"http:\/\/php.net\/docs.php\" target=\"_blank\" rel=\"noopener noreferrer\">PHP&#8217;s official documentation website<\/a> and the official WordPress <a href=\"https:\/\/codex.wordpress.org\/\" target=\"_blank\" rel=\"noopener noreferrer\">Codex<\/a> and <a href=\"http:\/\/developer.wordpress.org\/reference\" target=\"_blank\" rel=\"noopener noreferrer\">Code Reference<\/a>.<\/li>\n\n\n\n<li>If you want to make it easier to write the sort of CSS used in Method Two, check out a (free!) tool like <a href=\"http:\/\/getfirebug.com\/\">Firebug<\/a> if you use FireFox, or the Developer Tools for either <a href=\"http:\/\/developer.apple.com\/technologies\/tools\/\" target=\"_blank\" rel=\"noopener noreferrer\">Safari<\/a> or <a href=\"http:\/\/developers.google.com\/chrome-developer-tools\/docs\/overview\" target=\"_blank\" rel=\"noopener noreferrer\">Chrome<\/a>. They have &#8220;Inspector&#8221; tools that make it easy to find out what CSS is required to achieve a specific modification.<\/li>\n\n\n\n<li>If you want to hire a professional developer to assist you, check out a list of highly-rated customizers that we have compiled <a href=\"http:\/\/m.tri.be\/18k1\" target=\"_blank\" rel=\"noopener noreferrer\">here<\/a>.<\/li>\n\n\n\n<li>If you&#8217;d like to create members-only tickets, check out <a href=\"https:\/\/theeventscalendar.com\/extensions\/members-only-tickets\/\" target=\"_blank\" rel=\"noreferrer noopener\">this handy extension<\/a>!<\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>We are sometimes asked if The Events Calendar allows for the creation of &#8220;members-only&#8221; or &#8220;internal&#8221; calendar\u2014a calendar whose events can only be seen by logged-in users. Currently there is no &#8220;out of the box&#8221; way to make this sort of calendar\u2014no plugin setting, plugin filter, etc. But with a bit of custom coding, you&#8230;<\/p>\n","protected":false},"author":3,"featured_media":1955565,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"_kad_blocks_custom_css":"","_kad_blocks_head_custom_js":"","_kad_blocks_body_custom_js":"","_kad_blocks_footer_custom_js":"","_swpsp_post_exclude":false,"_kad_post_transparent":"","_kad_post_title":"","_kad_post_layout":"","_kad_post_sidebar_id":"","_kad_post_content_style":"","_kad_post_vertical_padding":"","_kad_post_feature":"","_kad_post_feature_position":"","_kad_post_header":false,"_kad_post_footer":false,"ep_exclude_from_search":false,"footnotes":""},"categories":[347],"tags":[23],"stellar-product-taxonomy":[161],"class_list":["post-1896509","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-how-to","tag-css","stellar-product-taxonomy-the-events-calendar"],"acf":[],"taxonomy_info":{"category":[{"value":347,"label":"How To"}],"post_tag":[{"value":23,"label":"CSS"}],"stellar-product-taxonomy":[{"value":161,"label":"The Events Calendar"}]},"featured_image_src_large":["https:\/\/images.theeventscalendar.com\/kb\/uploads\/2023\/02\/social-share-1024x538.png",1024,538,true],"author_info":{"display_name":"Jaime Marchwinski","author_link":"https:\/\/theeventscalendar.com\/knowledgebase\/author\/jaimetri-be\/"},"comment_info":0,"category_info":[{"term_id":347,"name":"How To","slug":"how-to","term_group":0,"term_taxonomy_id":347,"taxonomy":"category","description":"","parent":0,"count":109,"filter":"raw","term_order":"0","cat_ID":347,"category_count":109,"category_description":"","cat_name":"How To","category_nicename":"how-to","category_parent":0}],"tag_info":[{"term_id":23,"name":"CSS","slug":"css","term_group":0,"term_taxonomy_id":23,"taxonomy":"post_tag","description":"","parent":20,"count":10,"filter":"raw","term_order":"0"}],"_links":{"self":[{"href":"https:\/\/theeventscalendar.com\/knowledgebase\/wp-json\/wp\/v2\/posts\/1896509","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/theeventscalendar.com\/knowledgebase\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/theeventscalendar.com\/knowledgebase\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/theeventscalendar.com\/knowledgebase\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/theeventscalendar.com\/knowledgebase\/wp-json\/wp\/v2\/comments?post=1896509"}],"version-history":[{"count":4,"href":"https:\/\/theeventscalendar.com\/knowledgebase\/wp-json\/wp\/v2\/posts\/1896509\/revisions"}],"predecessor-version":[{"id":1970134,"href":"https:\/\/theeventscalendar.com\/knowledgebase\/wp-json\/wp\/v2\/posts\/1896509\/revisions\/1970134"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/theeventscalendar.com\/knowledgebase\/wp-json\/wp\/v2\/media\/1955565"}],"wp:attachment":[{"href":"https:\/\/theeventscalendar.com\/knowledgebase\/wp-json\/wp\/v2\/media?parent=1896509"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/theeventscalendar.com\/knowledgebase\/wp-json\/wp\/v2\/categories?post=1896509"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/theeventscalendar.com\/knowledgebase\/wp-json\/wp\/v2\/tags?post=1896509"},{"taxonomy":"stellar-product-taxonomy","embeddable":true,"href":"https:\/\/theeventscalendar.com\/knowledgebase\/wp-json\/wp\/v2\/stellar-product-taxonomy?post=1896509"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}